Make input parsing more defensive

master
Nick Krichevsky 2021-12-09 02:11:30 -05:00
parent e45adacf15
commit aec57c8690
1 changed files with 6 additions and 0 deletions

View File

@ -157,6 +157,12 @@ fn main() {
})
.collect::<Vec<_>>();
let first_row_length = input_lines.get(0).expect("input must be non-empty").len();
assert!(
input_lines.iter().all(|row| row.len() == first_row_length),
"All input lines must be the same length"
);
println!("Part 1: {}", part1(&input_lines));
println!("Part 2: {}", part2(&input_lines));
}