Complete day 5.2
This commit is contained in:
parent
561782748c
commit
c4a575870a
|
@ -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(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue