Complete day 5 #3

Merged
tlater merged 2 commits from tlater/day-5 into master 2020-12-08 00:54:38 +00:00
Showing only changes of commit 361285e23d - Show all commits

View file

@ -17,6 +17,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("{}", max_id?); println!("{}", max_id?);
// Part 2
let mut ids = input
.lines()
.map(|code| {
let (row, col) = find_seat(parse_seatcode(code)?);
Ok(row * 8 + col)
})
.collect::<Result<Vec<usize>, String>>()?;
ids.sort();
let mut previous = ids[0];
for id in &ids[1..] {
if id - 1 != previous {
println!("{}", id);
break;
} else {
previous = *id;
}
}
Ok(()) Ok(())
} }