|
@@ -0,0 +1,25 @@
|
|
|
+lines = []
|
|
|
+
|
|
|
+with open("5.input") as f:
|
|
|
+ for line in f.readlines():
|
|
|
+ lines.append(line)
|
|
|
+
|
|
|
+ids = []
|
|
|
+
|
|
|
+for line in lines:
|
|
|
+ head, tail = line[0:7], line[7:10]
|
|
|
+ row = int(head.replace('F', '0').replace('B', '1'), 2)
|
|
|
+ col = int(tail.replace('L', '0').replace('R', '1'), 2)
|
|
|
+ ids.append(row * 8 + col)
|
|
|
+
|
|
|
+print("Answer 1: {}".format(max(ids)))
|
|
|
+
|
|
|
+ids.sort()
|
|
|
+
|
|
|
+last_id = ids[0] - 1
|
|
|
+for id in ids:
|
|
|
+ if id != last_id + 1:
|
|
|
+ print("Answer 2: {}".format((id - 1)))
|
|
|
+ last_id = id
|
|
|
+
|
|
|
+
|