better name

This commit is contained in:
a 2020-12-17 13:07:48 -06:00
parent f00cad4c29
commit 798f8dddf3
1 changed files with 5 additions and 5 deletions

View File

@ -1,7 +1,7 @@
def main(d):
# create a set of tuples
seed = open('input.txt').read().split('\n')
state = set(
active = set(
(d - 2) * (0,) + (i, j) # zero-pad coords
for i, row in enumerate(seed)
for j, cell in enumerate(row)
@ -21,16 +21,16 @@ def main(d):
# do 6 iterations according to rules
from collections import Counter
for _ in range(6):
state = set(
active = set(
t
for t, count in Counter( # unpack the tuple and its count of neighboring active cells
tuple(map(sum, zip(t, n))) # add neighbors kernel to each active cell
for t in state
for t in active
for n in neighbors
).items()
if count == 3 or t in state and count == 2
if count == 3 or t in active and count == 2
)
return len(state)
return len(active)
print(main(3), main(4))