This commit is contained in:
parent
ba86d90e98
commit
d2af5b8bad
7 changed files with 10 additions and 4 deletions
1
11/11.py
1
11/11.py
|
@ -30,6 +30,7 @@ def check_flash(grid, f):
|
||||||
|
|
||||||
|
|
||||||
def flash(grid, x, y, f):
|
def flash(grid, x, y, f):
|
||||||
|
# pylint: disable=R0912
|
||||||
grid[y][x] = 0
|
grid[y][x] = 0
|
||||||
f += 1
|
f += 1
|
||||||
if y > 0: # upper neighbours
|
if y > 0: # upper neighbours
|
||||||
|
|
|
@ -30,6 +30,7 @@ def check_flash(grid, f):
|
||||||
|
|
||||||
|
|
||||||
def flash(grid, x, y, f):
|
def flash(grid, x, y, f):
|
||||||
|
# pylint: disable=R0912
|
||||||
grid[y][x] = 0
|
grid[y][x] = 0
|
||||||
f += 1
|
f += 1
|
||||||
if y > 0: # upper neighbours
|
if y > 0: # upper neighbours
|
||||||
|
|
1
14/14.py
1
14/14.py
|
@ -15,6 +15,7 @@ def parse_file(file):
|
||||||
|
|
||||||
def step_poly(poly_str, ruleset):
|
def step_poly(poly_str, ruleset):
|
||||||
new_p = []
|
new_p = []
|
||||||
|
p = None
|
||||||
for i, p in enumerate(poly_str):
|
for i, p in enumerate(poly_str):
|
||||||
if i + 1 == len(poly_str):
|
if i + 1 == len(poly_str):
|
||||||
break
|
break
|
||||||
|
|
|
@ -53,13 +53,13 @@ for s in range(40):
|
||||||
|
|
||||||
print(f'poly count: {poly_count}')
|
print(f'poly count: {poly_count}')
|
||||||
|
|
||||||
elements = set([k for key in poly_count.keys() for k in (key[0], key[1])])
|
elements = ([k for key, value in poly_count.items() for k in (key[0], key[1])])
|
||||||
print(f'elements: {elements}')
|
print(f'elements: {elements}')
|
||||||
elem_count = dict.fromkeys(elements, 0)
|
elem_count = dict.fromkeys(elements, 0)
|
||||||
|
|
||||||
for polymer in poly_count.keys():
|
for polymer, count in poly_count.items():
|
||||||
elem_count[polymer[0]] += poly_count[polymer]
|
elem_count[polymer[0]] += count
|
||||||
elem_count[polymer[1]] += poly_count[polymer]
|
elem_count[polymer[1]] += count
|
||||||
|
|
||||||
# remove double count, and fix first and last element
|
# remove double count, and fix first and last element
|
||||||
elem_count[first_last[0]] += 1
|
elem_count[first_last[0]] += 1
|
||||||
|
|
|
@ -15,6 +15,7 @@ def parse_file(file):
|
||||||
|
|
||||||
def step_poly(poly_str, ruleset):
|
def step_poly(poly_str, ruleset):
|
||||||
new_p = []
|
new_p = []
|
||||||
|
p = None
|
||||||
l_poly = len(poly_str)
|
l_poly = len(poly_str)
|
||||||
for i, p in enumerate(poly_str):
|
for i, p in enumerate(poly_str):
|
||||||
if i + 1 == l_poly:
|
if i + 1 == l_poly:
|
||||||
|
|
1
9/9.py
1
9/9.py
|
@ -21,6 +21,7 @@ def print_hmap(hmap):
|
||||||
|
|
||||||
|
|
||||||
def find_lowpoints(hmap):
|
def find_lowpoints(hmap):
|
||||||
|
# pylint: disable=R0912
|
||||||
lpoints = []
|
lpoints = []
|
||||||
|
|
||||||
# first line
|
# first line
|
||||||
|
|
1
9/9_2.py
1
9/9_2.py
|
@ -14,6 +14,7 @@ def parse_file(file):
|
||||||
|
|
||||||
|
|
||||||
def find_lowpoints(hmap):
|
def find_lowpoints(hmap):
|
||||||
|
# pylint: disable=R0912
|
||||||
lpoints = []
|
lpoints = []
|
||||||
|
|
||||||
# first line
|
# first line
|
||||||
|
|
Loading…
Reference in a new issue