diff --git a/2020/17/17.py b/2020/17/17.py index 5367d77..344d97c 100644 --- a/2020/17/17.py +++ b/2020/17/17.py @@ -12,9 +12,9 @@ def main(d): neighboring = [()] # list contains empty tuple which will be iterated over for _ in range(d): neighboring = [ - t + (x,) - for x in [-1, 0, 1] - for t in neighboring + _tuple + (offset,) + for offset in [-1, 0, 1] + for _tuple in neighboring ] neighboring.remove(d * (0,)) # this is the center cell @@ -22,13 +22,13 @@ def main(d): from collections import Counter for _ in range(6): 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 active - for n in neighboring + _tuple + for _tuple, count in Counter( # unpack the tuple and its count of neighboring active cells + tuple(map(sum, zip(_tuple, offset))) # add neighbors kernel to each active cell + for _tuple in active + for offset in neighboring ).items() - if count == 3 or t in active and count == 2 + if count == 3 or _tuple in active and count == 2 ) return len(active)