day 6 part 2

This commit is contained in:
Andy Teijelo 2023-12-07 11:54:11 -05:00
parent 228c5fb6d5
commit b2bd814c8a

View file

@ -17,13 +17,13 @@ fn parse_input() -> Result<(Vec<i64>, Vec<i64>)> {
for line in stdin().lines().map_while(Result::ok) { for line in stdin().lines().map_while(Result::ok) {
if line.starts_with("Time:") { if line.starts_with("Time:") {
times = numbers times = numbers
.captures_iter(&line) .captures_iter(&line.replace(' ', ""))
.map(|c| c.get(1).unwrap().as_str().parse()) .map(|c| c.get(1).unwrap().as_str().parse())
.map_while(Result::ok) .map_while(Result::ok)
.collect(); .collect();
} else if line.starts_with("Distance:") { } else if line.starts_with("Distance:") {
distances = numbers distances = numbers
.captures_iter(&line) .captures_iter(&line.replace(' ', ""))
.map(|c| c.get(1).unwrap().as_str().parse()) .map(|c| c.get(1).unwrap().as_str().parse())
.map_while(Result::ok) .map_while(Result::ok)
.collect(); .collect();