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