Skip to content

Commit 090b27a

Browse files
author
Chris Poch
committed
Final day 5
1 parent 86b0fa1 commit 090b27a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

5.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,33 @@ def getSeat(text):
3030

3131
lines = file.readlines()
3232
seats = []
33+
rows = {}
3334
for line in lines:
3435
(row, col) = getSeat(line)
36+
if row in rows:
37+
rows[row] = rows[row] + 1
38+
else:
39+
rows[row] = 1
3540
seats.append(row * 8 + col)
3641
total = total + 1
3742

3843
seats.sort(reverse=True)
3944
print(seats[0], total)
4045

41-
#part 2
46+
#part 2
47+
myRow = []
48+
for key in rows:
49+
#print(key, str(rows[key]))
50+
if rows[key] < 8:
51+
myRow.append(key)
52+
myRow.sort()
53+
if len(myRow) > 1:
54+
myRow = myRow[1]
55+
else:
56+
myRow = myRow[0]
57+
58+
for i in range(8):
59+
seatId = myRow * 8 + i
60+
if seatId not in seats:
61+
print(seatId)
62+
break

0 commit comments

Comments
 (0)