Day 10
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
signals = 0
|
||||
x = 1
|
||||
nxt = 20
|
||||
pos = 0
|
||||
signals, x, pos = 0, 1, 0
|
||||
|
||||
for line in lines:
|
||||
pos += 2 if line[0] == 'a' else 1
|
||||
if pos >= nxt:
|
||||
signals += nxt * x
|
||||
nxt += 40
|
||||
if line[0] == 'a':
|
||||
x += int(line[5:])
|
||||
is_add = line[0] == 'a'
|
||||
for _ in range(1 + is_add):
|
||||
pos += 1
|
||||
signals += pos * x if pos % 40 == 20 else 0
|
||||
x += int(line[5:]) if is_add else 0
|
||||
|
||||
print(signals)
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ sprite = 0
|
||||
crt = ''
|
||||
|
||||
for line in lines:
|
||||
crt += '#' if sprite <= len(crt) % 40 < sprite + 3 else ' '
|
||||
crt += '█' if sprite <= len(crt) % 40 < sprite + 3 else ' '
|
||||
if line[0] == 'a':
|
||||
crt += '#' if sprite <= len(crt) % 40 < sprite + 3 else ' '
|
||||
crt += '█' if sprite <= len(crt) % 40 < sprite + 3 else ' '
|
||||
sprite += int(line[5:])
|
||||
|
||||
for i in range(6):
|
||||
|
||||
Reference in New Issue
Block a user