This commit is contained in:
Stefan Bühler 2020-12-05 10:50:09 +01:00
parent 493336905c
commit ec9ae4a6ce
2 changed files with 876 additions and 0 deletions

845
data/day5/input Normal file
View File

@ -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
BFBBFBBRRL
BFFBBBBRLR
BBFBFFFRRR
FFFBFFBRLR
BFBFBBFLRL
BBFFFFBLRL
BBFFBBFRLL
FBBBFBFLRR
BFFBBBFLLL
BFBFBFBRRR
FBFFFBFRRL
FBBBFFFRLL
BFFBBFFRRL
BFFFBFBLLR
FBBFBFFLLR
BFBFBFBLLL
BBBFFFFRLR
FFBF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FBBBFFLLR
FBBFFFBRRR
BFBBFBFLRL
BBFFFFFRRL
FBFBBFBLLR
FBFBFFBLLR
FBBFBBBLRL
BFBBBFFRRL
FBBBFFFRRR
FFBBBFBLLL
FBFFBFFLLR
BFFBFFBRLL
FBFFFFBLLL
FFBFBFBLLL
FBBFFFFRLR
BFFBFFFLRR
FBBFFBFLLR

31
src/bin/day5.rs Normal file
View File

@ -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<Self> {
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;
}
}
}