Browse Source

Day 5 completed.

master
noirscape 1 year ago
parent
commit
668639b1d0
4 changed files with 1899 additions and 0 deletions
  1. +902
    -0
      5/puzzle 1/input.txt
  2. +44
    -0
      5/puzzle 1/main.py
  3. +902
    -0
      5/puzzle 2/input.txt
  4. +51
    -0
      5/puzzle 2/main.py

+ 902
- 0
5/puzzle 1/input.txt View File

@ -0,0 +1,902 @@
BBBFBFFRLL
FBBBBBFRRR
FBFFBBBRLR
FBBFBFBRLR
BBFBBFBLRL
BBFBFBBLLL
BBBBFFFRLL
FBBFFFBRRL
BFBFFBBRLL
BFFBFBBRLL
BBFFFBFRLR
FFBFBBBRRL
BBFFBFFLRL
FFBBBFFRLR
BFFFBFFRRL
BBFBFFFRRL
FBBFFFFRLL
FBBFFFBLRL
FBFFFFFRRR
FBBBFBFRLR
BFFBFFFRLR
BFBBBBFLLR
BBBBFFBLLR
FFFBBFFRRL
BBFBBFBLLL
BFBFBFBLRL
FFBBBFBLLR
FFFBFBFLRL
FBFBFBFLLL
FBBBFFBLLR
FBFBBFBLLR
FFFBFFFRLR
BFBBBFFRRL
FBFBBBBRLL
FBFFBFFLLR
BFFFFBFRLL
BFFBBFFRLL
FFBFBFFLLL
FFBBFFBRRR
BFFBBFBLLL
BBFBFBFLRL
BFBFFBFLRR
BFBBBFBRLL
FBBFFFFRRL
FFFBBBFLLL
FFBBBBFLLR
BBFBBFFRRL
BBFBBBFLLR
BBBFBFBLRR
BBFFFFFLRR
BFFBFFBLLR
FFFBFBFRLL
FBBBBFFRLR
BFBBBFFRRR
FBFFFFFRLR
BBFBBFFLRL
BBFFBFFLLR
FFBBBFBLRR
BBFBFBFRLR
FBBBFFFRLR
FFBFFFFLLL
FFBBFFBLLL
BBBFFBBRLL
BFFFFFBRLR
BBBFBFBLLL
FBFFFFFLLR
FBFFFFFLLL
FBBFBBBLRR
BBBFBFFRRL
FFBBFFBLRR
BBFBFBBRLL
BFBBFBBRLL
FFFBFFBRRR
BBBFBFBRRL
BFFBBFBRRL
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L"
]
def get_seat_info(boarding_id):
available_rows = list(range(0, 128))
for character in boarding_id[:7]: # [:x] means characters up to x
if character == "F":
available_rows = available_rows[:round(len(available_rows)/2)]
elif character == "B":
available_rows = available_rows[round(len(available_rows)/2):]
else:
raise Exception("Impossible boarding ID! [ROW]")
row = available_rows[0]
available_columns = list(range(0, 8))
for character in boarding_id[-3:]: # [x:] means at most characters from x, negative wraps
if character == "L":
available_columns = available_columns[:round(len(available_columns)/2)]
elif character == "R":
available_columns = available_columns[round(len(available_columns)/2):]
else:
raise Exception("Impossible boarding ID! [COLUMN]")
column = available_columns[0]
seat_id = row * 8 + column
return row, column, seat_id
def main(lines):
highest_seat_id = 0
for line in lines:
row, column, seat_id = get_seat_info(line)
print(f"{row=} {column=} {seat_id=}")
if seat_id > highest_seat_id:
highest_seat_id = seat_id
print(f"{highest_seat_id=}")
main(lines)
handle.close()

+ 902
- 0
5/puzzle 2/input.txt View File

@ -0,0 +1,902 @@
BBBFBFFRLL
FBBBBBFRRR
FBFFBBBRLR
FBBFBFBRLR
BBFBBFBLRL
BBFBFBBLLL
BBBBFFFRLL
FBBFFFBRRL
BFBFFBBRLL
BFFBFBBRLL
BBFFFBFRLR
FFBFBBBRRL
BBFFBFFLRL
FFBBBFFRLR
BFFFBFFRRL
BBFBFFFRRL
FBBFFFFRLL
FBBFFFBLRL
FBFFFFFRRR
FBBBFBFRLR
BFFBFFFRLR
BFBBBBFLLR
BBBBFFBLLR
FFFBBFFRRL
BBFBBFBLLL
BFBFBFBLRL
FFBBBFBLLR
FFFBFBFLRL
FBFBFBFLLL
FBBBFFBLLR
FBFBBFBLLR
FFFBFFFRLR
BFBBBFFRRL
FBFBBBBRLL
FBFFBFFLLR
BFFFFBFRLL
BFFBBFFRLL
FFBFBFFLLL
FFBBFFBRRR
BFFBBFBLLL
BBFBFBFLRL
BFBFFBFLRR
BFBBBFBRLL
FBBFFFFRRL
FFFBBBFLLL
FFBBBBFLLR
BBFBBFFRRL
BBFBBBFLLR
BB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BFFBBBBLLL
BFBBBBFRRR
BFBBBBFRLR
FFFBFBFRLR
BFBBFBFLLR
BFFBFFFLLR
BFFFFFFRLL
BFFBBBFRLL
FBFFBBBLRR
BBFFBBBRLR
FBFFFFFLRR
BBFFBFFLLL
FBFFFFBLRR
BBFFBFBRLR
FBFBFFFRRL
FBBFFBFLLL

+ 51
- 0
5/puzzle 2/main.py View File

@ -0,0 +1,51 @@
handle = open("input.txt", "r")
lines = [line.rstrip() for line in handle.readlines()]
test_lines = [
"BFFFBBFRRR",
"FFFBBBFRRR",
"BBFFBBFRLL"
]
def get_seat_info(boarding_id):
available_rows = list(range(0, 128))
for character in boarding_id[:7]: # [:x] means characters up to x
if character == "F":
available_rows = available_rows[:round(len(available_rows)/2)]
elif character == "B":
available_rows = available_rows[round(len(available_rows)/2):]
else:
raise Exception("Impossible boarding ID! [ROW]")
row = available_rows[0]
available_columns = list(range(0, 8))
for character in boarding_id[-3:]: # [x:] means at most characters from x, negative wraps
if character == "L":
available_columns = available_columns[:round(len(available_columns)/2)]
elif character == "R":
available_columns = available_columns[round(len(available_columns)/2):]
else:
raise Exception("Impossible boarding ID! [COLUMN]")
column = available_columns[0]
seat_id = row * 8 + column
return row, column, seat_id
def main(lines):
highest_seat_id = 0
seat_ids = []
for line in lines:
row, column, seat_id = get_seat_info(line)
print(f"{row=} {column=} {seat_id=}")
if seat_id > highest_seat_id:
highest_seat_id = seat_id
seat_ids.append(seat_id)
total_amount_of_seats = list(range(0, highest_seat_id+1))
for seat_id in seat_ids:
total_amount_of_seats.remove(seat_id)
your_seat = total_amount_of_seats[-1]
print(f"{your_seat=}")
print(f"{highest_seat_id=}")
main(lines)
handle.close()

Loading…
Cancel
Save