Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def day21_part2(s):
- empty = np.tile(np.array([list(line) for line in s.splitlines()]) != '#', (5, 5))
- a = np.zeros((657, 657), bool)
- a[328, 328] = 1
- for _ in range(327):
- a[1:-1, 1:-1] = empty & (a[:-2, 1:-1] | a[2:, 1:-1] | a[1:-1, :-2] | a[1:-1, 2:])
- counts = a[1:-1, 1:-1].reshape(5, 131, 5, 131).sum((1, 3)).flat
- return (
- counts[12] * 40924885401
- + counts[7] * 40925290000
- + counts[[1, 3, 21, 23]].sum() * 202300
- + counts[[6, 8, 16, 18]].sum() * 202299
- + counts[[2, 10, 14, 22]].sum()
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement