parent
9d359082d3
commit
c51e2f1a3a
5 changed files with 87 additions and 0 deletions
@ -0,0 +1,10 @@ |
||||
199 |
||||
200 |
||||
208 |
||||
210 |
||||
200 |
||||
207 |
||||
240 |
||||
269 |
||||
260 |
||||
263 |
@ -0,0 +1,6 @@ |
||||
forward 5 |
||||
down 5 |
||||
forward 8 |
||||
up 3 |
||||
down 8 |
||||
forward 2 |
@ -0,0 +1,39 @@ |
||||
lines = open("input.txt", 'r').read().splitlines() |
||||
draw = [int(i) for i in lines[0].split(",")] |
||||
boards = [] |
||||
for s in range(2, len(lines),6): |
||||
boards.append([[int(j) for j in lines[i].split()] for i in range(s,s+5)]) |
||||
|
||||
earliestWin = len(draw) |
||||
winBoard = 0 |
||||
|
||||
for b in range(0, len(boards)): |
||||
for i in range(0, 5): |
||||
latest = 0 |
||||
for j in range(0, 5): |
||||
if boards[b][i][j] not in draw: |
||||
break |
||||
index = draw.index(boards[b][i][j]) |
||||
if index > latest: |
||||
latest = index |
||||
if latest < earliestWin and latest != 0: |
||||
earliestWin = latest |
||||
winBoard = int(b) |
||||
latest = 0 |
||||
for j in range(0, 5): |
||||
if boards[b][j][i] not in draw: |
||||
break |
||||
index = draw.index(boards[b][j][i]) |
||||
if index > latest: |
||||
latest = index |
||||
if latest < earliestWin and latest != 0: |
||||
earliestWin = latest |
||||
winBoard = b |
||||
|
||||
summa = 0 |
||||
for row in boards[winBoard]: |
||||
for n in row: |
||||
if n not in draw[:earliestWin+1]: |
||||
summa += n |
||||
|
||||
print(draw[earliestWin]*summa) |
@ -0,0 +1,19 @@ |
||||
7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1 |
||||
|
||||
22 13 17 11 0 |
||||
8 2 23 4 24 |
||||
21 9 14 16 7 |
||||
6 10 3 18 5 |
||||
1 12 20 15 19 |
||||
|
||||
3 15 0 2 22 |
||||
9 18 13 17 5 |
||||
19 8 7 25 23 |
||||
20 11 10 24 4 |
||||
14 21 16 12 6 |
||||
|
||||
14 21 17 24 4 |
||||
10 16 15 9 19 |
||||
18 8 23 26 20 |
||||
22 11 13 6 5 |
||||
2 0 12 3 7 |
Loading…
Reference in new issue