Files
advent-of-code/2022/10/part2

33 lines
531 B
Plaintext
Raw Permalink Normal View History

2022-12-10 08:12:17 +00:00
#!/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))