diff --git a/2020/17/17.py b/2020/17/17.py index beb8462..5367d77 100644 --- a/2020/17/17.py +++ b/2020/17/17.py @@ -9,14 +9,14 @@ def main(d): ) # generate all tuples -1..1 in all dimensions - neighbors = [()] # list contains empty tuple which will be iterated over + neighboring = [()] # list contains empty tuple which will be iterated over for _ in range(d): - neighbors = [ + neighboring = [ t + (x,) for x in [-1, 0, 1] - for t in neighbors + for t in neighboring ] - neighbors.remove(d * (0,)) # this is the center cell + neighboring.remove(d * (0,)) # this is the center cell # do 6 iterations according to rules from collections import Counter @@ -26,7 +26,7 @@ def main(d): 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 active - for n in neighbors + for n in neighboring ).items() if count == 3 or t in active and count == 2 )