From b623f6772ad6ef6098ec51e9be9d722e9a0f04dd Mon Sep 17 00:00:00 2001 From: kalle Date: Sat, 5 Dec 2020 14:26:54 +0100 Subject: [PATCH] Day 5 --- Day 5/input | 815 +++++++++++++++++++++++++++++++++++++++++++++++++++ Day 5/one.py | 33 +++ Day 5/two.py | 37 +++ 3 files changed, 885 insertions(+) create mode 100644 Day 5/input create mode 100755 Day 5/one.py create mode 100755 Day 5/two.py diff --git a/Day 5/input b/Day 5/input new file mode 100644 index 0000000..8699311 --- /dev/null +++ b/Day 5/input @@ -0,0 +1,815 @@ +BFBBFFFLRR +FFBFBBBLLL +FBFBFBFLLL +BBFFFBFLLR +FBFFBBFLRR +BBFBFFFLLL +FFBBFFFRLL +BFBFBBBRRR +FBFFBFFRLR +FBBBBBBLLL +BBFBBBBLLL +BFFFBBBLLL +FFBFFFBRLR +BFFFFBFLLR +FFBBBFBLRL +BFFBFBBRRL +FBFBFBBRRR +FBFFFBBRRL +FBFBBBFRLR +BFFFFFBRRL +BBFFFBBLRR +FFBBBBBRRR +FFBBBBBLLL +BBFBFFBRLR +FBFFBFBRRR +FFFBBBBRLL +BBFBFFBLLR +BFBFFFBRLL +FFBFBFFLLR +FBFBBFBRLL +FBFFBBBLLL +FBFBBBFRLL +FBFBFBBRLL +BFFFFBBRLL +FFFBBFFLLR +FFBFFFBLRL +FFBFBBFLLL +BFBBFBBLLL +BFFFFBBRRL +FFBFFFBRLL +BFBBFFFRRR +FFBBFFFLRL +FFBFBFBRLL +BFBFBBBLLL +BBFBBFFLRL +BFFFFBBLLR +FFBFBBFRLR +FFBBFBBLLR +FBFFBBFLLL +BFBFBFBLLL +BFFBFBBLLR +FBBBBFFRLR +FBBBFBFRLL +FBBBBFFLRR +BFFBBBBLRL +FBFFBBFLRL +BBFFFBBLLR +FBFBFFFRLL +FBBBFBBRRL +FFBBBFBLLR +BFFBBBFLLR +BFFFFBFRLR +BBFFFFBLLR +FBBFFFBRRL +BFFFBFBRRR +FBFBFFFRRR +BB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+FBBFBFFRRR +BFBBFBFRLL +FFFBBBBRRL +FBFBFFBRRL diff --git a/Day 5/one.py b/Day 5/one.py new file mode 100755 index 0000000..05c4374 --- /dev/null +++ b/Day 5/one.py @@ -0,0 +1,33 @@ +#!/bin/python + +with open("input", 'r') as input: + seat_id_max = 0 + for line in input: + line = line.strip() + row_lower = 0 + row_upper = 127 + + col_lower = 0 + col_upper = 7 + + row_chars = line[:7] + col_chars = line[7:] + + for char in row_chars: + if char == 'F': + row_upper = (row_lower + row_upper) // 2 + elif char == 'B': + row_lower = (row_lower + row_upper) // 2 + + for char in col_chars: + if char == 'L': + col_upper = (col_lower + col_upper) // 2 + elif char == 'R': + col_lower = (col_lower + col_upper) // 2 + + seat_id = row_upper * 8 + col_upper + + seat_id_max = max(seat_id, seat_id_max) + + print(seat_id_max) + diff --git a/Day 5/two.py b/Day 5/two.py new file mode 100755 index 0000000..3d16cae --- /dev/null +++ b/Day 5/two.py @@ -0,0 +1,37 @@ +#!/bin/python + +with open("input", 'r') as input: + possible_seats = dict(zip([i for i in range(127 * 8 + 8)], [True for _ in range(127 * 8 + 8)])) + for line in input: + line = line.strip() + row_lower = 0 + row_upper = 127 + + col_lower = 0 + col_upper = 7 + + row_chars = line[:7] + col_chars = line[7:] + + for char in row_chars: + if char == 'F': + row_upper = (row_lower + row_upper) // 2 + elif char == 'B': + row_lower = (row_lower + row_upper) // 2 + + for char in col_chars: + if char == 'L': + col_upper = (col_lower + col_upper) // 2 + elif char == 'R': + col_lower = (col_lower + col_upper) // 2 + + seat_id = row_upper * 8 + col_upper + + possible_seats[seat_id] = False + + for seat_id in possible_seats: + try: + if possible_seats[seat_id] and not possible_seats[seat_id - 1] and not possible_seats[seat_id + 1]: + print(seat_id) + except: + pass