diff --git a/src/main.rs b/src/main.rs index 6a7e06a..d98d83a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,9 +8,9 @@ fn main() { println!(); -// for arg in args { -// println!("{:?}\n{:?}\n", arg, stati(arg)); -// }; + for arg in &args { + println!("{:?}\n{:?}\n", arg, stati(arg)); + }; let strings = args[0]; @@ -53,11 +53,7 @@ fn stati(s: &str) -> String { .map( |m| m.split('|') .filter_map(|e| e.parse::().ok()) // handle invalid parse - .collect::>() - .chunks(3) - .map(|c| (c[0],c[1],c[2])) - .map(|(h,m,s)| h*3600 + m*60 + s) - .sum() + .fold(0, |a, i| a*60+i) // switch to accumulater ) .collect::>(); @@ -96,5 +92,6 @@ mod tests { "Range: 01|01|18 Average: 01|38|05 Median: 01|32|34"); dotest("02|15|59, 2|47|16, 02|17|20, 2|32|34, 2|17|17, 2|22|00, 2|31|41", "Range: 00|31|17 Average: 02|26|18 Median: 02|22|00"); + dotest("",""); } }