You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
619 B
29 lines
619 B
lines = open('input.txt', "r").read().splitlines()
|
|
|
|
cycle = 0
|
|
x = 1
|
|
end = [40, 80, 120, 160, 200, 240]
|
|
registers = [999999 for y in range(240)]
|
|
for line in lines:
|
|
cmd = line.split(" ")
|
|
registers[cycle] = x
|
|
if cmd[0] == "noop":
|
|
cycle += 1
|
|
else:
|
|
registers[cycle+1] = x
|
|
cycle += 2
|
|
x += int(cmd[1])
|
|
|
|
pixel_pos = 0
|
|
screen = ""
|
|
for r in range(len(registers)):
|
|
if r in end:
|
|
screen += "\n"
|
|
pixel_pos = 0
|
|
if pixel_pos in [registers[r]-1, registers[r], registers[r]+1]:
|
|
screen += "#"
|
|
else:
|
|
screen += "."
|
|
pixel_pos += 1
|
|
|
|
print(screen) |