-
Notifications
You must be signed in to change notification settings - Fork 0
/
10.py
37 lines (28 loc) · 829 Bytes
/
10.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
from utils import puzzle_input
def determine_symbol(cycle, sprite_idx):
if sprite_idx <= cycle % 40 <= sprite_idx + 2:
return "▓"
else:
return "░"
def solve(inp):
cycle = 1
X = 1
total_strength = 0
for line in inp.split("\n"):
print(determine_symbol(cycle, X), end="")
cycle += 1
chunks = line.split(" ")
if chunks[0] == "addx":
if cycle % 40 == 20:
total_strength += cycle * X
elif cycle % 40 == 1:
print()
print(determine_symbol(cycle, X), end="")
cycle += 1
X += int(chunks[1])
if cycle % 40 == 20:
total_strength += cycle * X
elif cycle % 40 == 1:
print()
print(total_strength)
solve(puzzle_input("10"))