better variable names
This commit is contained in:
parent
12e4a4b1c7
commit
da2f849986
|
@ -12,9 +12,9 @@ def main(d):
|
||||||
neighboring = [()] # list contains empty tuple which will be iterated over
|
neighboring = [()] # list contains empty tuple which will be iterated over
|
||||||
for _ in range(d):
|
for _ in range(d):
|
||||||
neighboring = [
|
neighboring = [
|
||||||
t + (x,)
|
_tuple + (offset,)
|
||||||
for x in [-1, 0, 1]
|
for offset in [-1, 0, 1]
|
||||||
for t in neighboring
|
for _tuple in neighboring
|
||||||
]
|
]
|
||||||
neighboring.remove(d * (0,)) # this is the center cell
|
neighboring.remove(d * (0,)) # this is the center cell
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@ def main(d):
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
for _ in range(6):
|
for _ in range(6):
|
||||||
active = set(
|
active = set(
|
||||||
t
|
_tuple
|
||||||
for t, count in Counter( # unpack the tuple and its count of neighboring active cells
|
for _tuple, 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
|
tuple(map(sum, zip(_tuple, offset))) # add neighbors kernel to each active cell
|
||||||
for t in active
|
for _tuple in active
|
||||||
for n in neighboring
|
for offset in neighboring
|
||||||
).items()
|
).items()
|
||||||
if count == 3 or t in active and count == 2
|
if count == 3 or _tuple in active and count == 2
|
||||||
)
|
)
|
||||||
|
|
||||||
return len(active)
|
return len(active)
|
||||||
|
|
Loading…
Reference in a new issue