We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 86b0fa1 commit 090b27aCopy full SHA for 090b27a
5.py
@@ -30,12 +30,33 @@ def getSeat(text):
30
31
lines = file.readlines()
32
seats = []
33
+ rows = {}
34
for line in lines:
35
(row, col) = getSeat(line)
36
+ if row in rows:
37
+ rows[row] = rows[row] + 1
38
+ else:
39
+ rows[row] = 1
40
seats.append(row * 8 + col)
41
total = total + 1
42
43
seats.sort(reverse=True)
44
print(seats[0], total)
45
-#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
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