diff options
Diffstat (limited to 'problem10.py')
| -rw-r--r-- | problem10.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/problem10.py b/problem10.py new file mode 100644 index 0000000..41ce1eb --- /dev/null +++ b/problem10.py @@ -0,0 +1,38 @@ +from common import day + +fh = open(f"input/{day()}") +X = 1 +cycle = 0 +r = 0 +row = [] +while True: + cycle += 1 + pos = (cycle - 1) % 40 + if pos == 0: + print("".join(row)) + row = [] + if pos in (X-1, X, X+1): + row.append("#") + else: + row.append(".") + try: + line = next(fh) + except StopIteration: + print(r) + break + line = line.rstrip() + match line.split(): + case ["noop"]: + continue + case ["addx", val]: + val = int(val) + cycle += 1 + pos = (cycle - 1) % 40 + if pos == 0: + print("".join(row)) + row = [] + if pos in (X-1, X, X+1): + row.append("#") + else: + row.append(".") + X += val |
