-
Notifications
You must be signed in to change notification settings - Fork 0
/
day10.py
83 lines (66 loc) · 1.28 KB
/
day10.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from collections import Counter
from aocd import get_data
from aocd import submit
lines = get_data(year=2022, day=10)
lines = lines.split("\n")
'''
with open('testcases.txt') as f:
lines = f.readlines()
lines = [x.replace('\n',"") for x in lines]
#'''
a=[]
for line in lines:
b=line.split()
if(b[0]=="noop"):
a.append((0,0))
else:
a.append((1,int(b[1])))
#print(a)
ansl = [20, 60, 100, 140, 180, 220]
x=1
addp = 0
addc = 0
i=1
a2 = []
for b in a:
#print(f"{i} - {b[1]} - {x}")
if(b[0]==0):
a2.append((i,x))
i = i+1
else:
a2.append((i,x))
i=i+1
addc = b[1]
a2.append((i,x))
x = x + addc
i=i+1
#print(a2)
a3 = list(filter(lambda x: x[0] in ansl,a2))
a4 = sum(list(map(lambda x: x[1]*x[0],a3)))
#print(a3)
print(a4)
#submit(a4)
print(a2)
a3 = []
for i in range(0,240):
flag = 0
i2 = i%40
#print(f"{i} {i2}")
if ((i+1,i2-1) in a2):
flag=1
if ((i+1,i2) in a2):
flag=1
if ((i+1,i2+1) in a2):
flag=1
print(f"{i} {i2} {flag}")
a3.append(flag)
for i in range(6):
for j in range(40):
c = a3[i*40+j]
if(c==0):
print(".",end="")
else:
print("#",end="")
print()
print()
#submit("RZHFGJCB")