1
0
Fork 0

2017 day 22 part 1

This commit is contained in:
Lucidiot 2020-12-07 02:40:23 +01:00
parent 47b3d9fc19
commit 336341abce
Signed by: lucidiot
GPG Key ID: 3358C1CA6906FB8D
2 changed files with 20 additions and 1 deletions

19
2017/22/virus.py Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env python3
import sys
from collections import defaultdict
data = [l.strip() for l in sys.stdin.readlines()]
grid = defaultdict(bool)
for i, row in enumerate(data):
for j, col in enumerate(row):
grid[complex(j, i)] = (col == "#")
pos, d = complex(len(data) // 2, len(data[0]) // 2), 1j
becomeinfected = 0
for _ in range(10000):
if grid[pos]:
d *= 1j
else:
d *= -1j
becomeinfected += 1
grid[pos] = not grid[pos]
pos += d
print(becomeinfected)

View File

@ -14,7 +14,7 @@ My solutions to the Advent of Code puzzles.
6 ██ ██ ██
7 ██ ██
8 ██ ██
9 ██
9 ██
10 ██ ██
11 ██ ██
12 ██ ██