diff --git a/day6/src/main.rs b/day6/src/main.rs index babcee7..a5f6430 100644 --- a/day6/src/main.rs +++ b/day6/src/main.rs @@ -2,17 +2,14 @@ use std::fs; fn main() { let input = fs::read_to_string("input.txt").unwrap(); - let input: Vec<_> = input.split('\n') // Seperate the Time and Distance lines + let input: Vec<_> = input.split('\n') // Separate the Time and Distance lines .map(|line| { - &line[line.find(':').unwrap() + 1..] // Drop "Time:" and "Distance:" - }).map(|line| { - line.split_whitespace() // Split the numbers into their own elements + line[line.find(':').unwrap() + 1..] // Drop "Time:" and "Distance:" + .split_whitespace() // Split the numbers into their own elements .flat_map(|s| s.chars()).collect::() // Combine the strings into a single one - }).map(|num| { - num.parse::().expect("Couldn't parse number") // Parse numbers into i32 + .parse::().expect("Couldn't parse number") // Parse numbers into i32 }).collect(); // Collect into Vec - let time = input[0]; let dist = input[1]; let mut valid = 0; @@ -32,14 +29,13 @@ fn main() { // fn main() { // let input = fs::read_to_string("input.txt").unwrap(); -// let input: Vec<_> = input.split('\n') // Seperate the Time and Distance lines -// .map(|line| { -// &line[line.find(':').unwrap() + 1..] // Drop "Time:" and "Distance:" -// }).map(|line| { -// line.split_whitespace() // Split the numbers into their own elements. -// .map(|num| num.parse::().expect("Couldn't parse number")) // Parse numbers into i32 -// .collect::>() -// }).collect(); // collect into Vec +// let input: Vec<_> = input.split('\n') // Separate the Time and Distance lines +// .map(|line| { +// line[line.find(':').unwrap() + 1..] // Drop "Time:" and "Distance:" +// .split_whitespace() // Split the numbers into their own elements. +// .map(|num| num.parse::().expect("Couldn't parse number")) // Parse numbers into i32 +// .collect::>() +// }).collect(); // collect into Vec // let mut valid_total = 1;