-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaoc2210.py
51 lines (46 loc) · 835 Bytes
/
aoc2210.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
a = []
# with open('2210.1') as file:
with open('2210.0') as file:
for line in file:
l = line.strip().split()
a.append(0)
if len(l) == 2:
v = int(l[1])
a.append(v)
# print(a, len(a))
x = 1
r = 0
i = 0
cc = 0
while True:
if i == len(a):
i %= len(a)
n = a[i]
if i + 1 == 20 or (i + 1) % 40 == 20:
r += (i + 1) * x
i += 1
x += n
cc += 1
if cc == 220:
break
# part 2
ss = ''
x = 1
i = 0
cc = 0
while True:
if i == len(a):
i %= len(a)
if (i % 40) in [x - 1, x, x + 1]:
ss += '@'
else:
ss += ' '
if (i + 1) % 40 == 0:
ss += '\n'
x += a[i]
cc += 1
if cc == 240: # (?) missing something if 220
break
i += 1
print('Star 1:', r)
print('Star 2: \n\n' + ss)