2022 day 10
This commit is contained in:
32
2022/10/part2
Executable file
32
2022/10/part2
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
CLOCK = 0
|
||||
X = 1
|
||||
OUT = []
|
||||
|
||||
def clock():
|
||||
global CLOCK, X, OUT
|
||||
pos = CLOCK%40
|
||||
|
||||
if X == pos or X-1 == pos or X+1 == pos:
|
||||
OUT.append('#')
|
||||
else:
|
||||
OUT.append('.')
|
||||
|
||||
if pos == 39:
|
||||
OUT.append("\n")
|
||||
|
||||
CLOCK += 1
|
||||
|
||||
with open('input') as f:
|
||||
for line in f:
|
||||
ins, *args = line.rstrip().split(" ")
|
||||
|
||||
if ins == "noop":
|
||||
clock()
|
||||
elif ins == "addx":
|
||||
clock()
|
||||
clock()
|
||||
X += int(args[0])
|
||||
|
||||
print(''.join(OUT))
|
Reference in New Issue
Block a user