33 lines
531 B
Python
Executable File
33 lines
531 B
Python
Executable File
#!/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))
|