We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 22f77b9 commit 9bb54b1Copy full SHA for 9bb54b1
day10.py
@@ -0,0 +1,26 @@
1
+with open("inputs/day10.txt", "r") as data:
2
+ signals = [0]
3
+ x = 1
4
+ last_idx = 1
5
+ idx = 1
6
+ buff = ""
7
+ result = 0
8
+ for instr in data.read().splitlines():
9
+ if instr.startswith("noop"):
10
+ signals.extend([x])
11
+ else:
12
+ signals.extend([x,x])
13
+ x += int(instr.split(" ")[1])
14
+ idx = len(signals)
15
+ for i in range(last_idx, idx):
16
+ if abs(signals[i] - (i - 1) % 40) < 2:
17
+ buff += "#"
18
19
+ buff += "."
20
+ if i % 40 == 0:
21
+ print(buff)
22
23
+ if i % 40 == 20 and i < 221:
24
+ result += signals[i] * i
25
+ last_idx = idx
26
+ print('Part1: ', result)
0 commit comments