2022 day 10

This commit is contained in:
2022-12-10 08:12:17 +00:00
parent c474e4b25e
commit 47a16a9b6a
4 changed files with 205 additions and 2 deletions

32
2022/10/part2 Executable file
View 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))