day6 part2 rev

This commit is contained in:
Candygoblen123 2023-12-06 11:03:00 -05:00
parent 5211c5dfe7
commit 0c4376d503
No known key found for this signature in database
GPG Key ID: 577DA64EBEF10385

View File

@ -6,10 +6,11 @@ fn main() {
.map(|line| { .map(|line| {
&line[line.find(':').unwrap() + 1..] // Drop "Time:" and "Distance:" &line[line.find(':').unwrap() + 1..] // Drop "Time:" and "Distance:"
}).map(|line| { }).map(|line| {
line.split_whitespace().flat_map(|s| s.chars()).collect::<String>() // Split the numbers into their own elements. line.split_whitespace() // Split the numbers into their own elements
}) .flat_map(|s| s.chars()).collect::<String>() // Combine the strings into a single one
.map(|num| num.parse::<i64>().expect("Couldn't parse number")) // Parse numbers into i32 }).map(|num| {
.collect(); // collect into Vec num.parse::<i64>().expect("Couldn't parse number") // Parse numbers into i32
}).collect(); // Collect into Vec
let time = input[0]; let time = input[0];