-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday10.py
executable file
·47 lines (36 loc) · 850 Bytes
/
day10.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
from aoc_utils import * # type: ignore
from aocd import get_data
data = get_data(year=2022, day=10, block=True)
lines = iter(data.splitlines())
t = 0
X = 1
i = 1
waiting = 0
px = 0
try:
while True:
dx, dy = px%40, px // 40
px += 1
if dx == X or dx == X-1 or dx == X+1:
print('#', end='')
else:
print('.', end='')
if px % 40 == 0:
print()
if waiting:
X += waiting
waiting = 0
else:
line = next(lines)
if line.startswith("noop"):
pass
else:
_, waiting = line.split()
waiting = int(waiting)
i += 1
if (i + 20) % 40 == 0:
t += X * i
except StopIteration:
pass
# print(t) - Part 1