From ec9ae4a6cef870ce80f4f4834db51c4fac36f314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 5 Dec 2020 10:50:09 +0100 Subject: [PATCH] day5 --- data/day5/input | 845 ++++++++++++++++++++++++++++++++++++++++++++++++ src/bin/day5.rs | 31 ++ 2 files changed, 876 insertions(+) create mode 100644 data/day5/input create mode 100644 src/bin/day5.rs diff --git a/data/day5/input b/data/day5/input new file mode 100644 index 0000000..19e3a2c --- /dev/null +++ b/data/day5/input @@ -0,0 +1,845 @@ +FFBFBFBRRL +FBFFBFBLRR +FFFBBFBRLR +FBBFFBFRRR +FBBBFFFLRR +FBBBFFBRRL +FBBBBFBRRL +BFBBFFBLLL +BBFFFFFRRR +BFBFFBFLRR +FBFFFBBRRR +BFBFBFBLRR +FFFBFBBRRL +BFBFFBFRRL +FBFFFBBRLR +FFBBFFBLRR +FFBFBBBLLR +FBFFBFBLLR +BBBFFFFLRR +FFBBBBBRLR +FBBBBFBLLL +FFFBFBFLRR +FFBFFFFRLL +FBBFFFFRRR +BFFFBBFRLR +BFBBFFFLRR +FBBBBFBRRR +FBFFBFBLLL +BBFBFFFRRL +FBBBFBBRRR +BBFFFFBLLL +FFFBFFBLRR +FFBFFBBRLL +BBBFFFFRLL +BFBBBBBLRR +FFBBFBBLRL +BFBFBFFLLL +FBFBBFFRLL +FFFBBFBLLR +FBBBBBFRRL +BFBFBBBRLR +FBBBFBFLLL +FBBFFFFLRL +BFBBBFBRRL +FFBBFFFRRR +BFBFBFFRLL +FBFBBBBLLR +FBFBBBFRLL +BFFBBBFLRR +BFFFBBFLLR +BFBFBBBLRR +BFBFFFBRRR +BBBFFFFLRL +FBFBBFFLRL +FBBFFBBLLR +FBBFBFBRLL +FBFFBBFRLR +BFBFBBBLLL +FBBFBBFLLL +BFBFBBBRLL +BBFFFFFRLL +BFBBFFFLLL +BFFFFFFRLR +FBFFBFFLRR +FFFBBBFRLR +BFFBBBFRRL +BFBBFB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BFFBLLL +FBBFFFBLRL +FFFBFFFLLR +BBFFFFFRLR +BFFFFBBLLR +FBFBBBFLLR +BFFBFFFRLL +BBBFFFFLLR +FBFBBFBLRL +FFBBFFBRRL +FBFBFBFRLR +BFBBBFBRRR +BFFFFBBRRL +FFFBBBBRRL +FFFBFFBLLL +FBFFFFBLRR +BBFBFFFRLR +FFBBBFFLLR +FBBFFFBRRR +BFBBFBFLRL +BBFFFFFRRL +FBFBBFBLLR +FBFBFFBLLR +FBBFBBBLRL +BFBBBFFRRL +FBBBFFFRRR +FFBBBFBLLL +FBFFBFFLLR +BFFBFFBRLL +FBFFFFBLLL +FFBFBFBLLL +FBBFFFFRLR +BFFBFFFLRR +FBBFFBFLLR diff --git a/src/bin/day5.rs b/src/bin/day5.rs new file mode 100644 index 0000000..a0a8f77 --- /dev/null +++ b/src/bin/day5.rs @@ -0,0 +1,31 @@ +const INPUT: &str = include_str!("../../data/day5/input"); + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)] +struct Seat { + id: u16, +} + +impl Seat { + fn parse(data: &str) -> Self { + let data = data.trim(); + assert_eq!(data.len(), 10); + let id = data.chars().map(|c| c == 'B' || c == 'R').fold(0, |mask, bit| mask * 2 + if bit { 1 } else { 0 }); + Self { id } + } + + fn parse_list(input: &str) -> Vec { + input.lines().map(Seat::parse).collect() + } +} + +fn main() { + let mut seats = Seat::parse_list(INPUT); + println!("Max Seat id: {}", seats.iter().max().unwrap().id); + seats.sort(); + for i in 0..seats.len()-1 { + if seats[i].id + 1 != seats[i+1].id { + println!("Empty seat: {}", seats[i].id + 1); + break; + } + } +}