diff --git a/src/main.rs b/src/main.rs index ab7be1e..e3b2a5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,21 +20,31 @@ fn main() { let hms = Regex::new(r"(\d\d?)\|(\d\d)\|(\d\d)").unwrap(); let csv = Regex::new(r", ").unwrap(); + let dig = Regex::new(r"\D+").unwrap(); let parse_int = |m: Option| { m.unwrap().as_str().parse::().unwrap() }; +// let mut vec = +// hms.captures_iter(test) +// .map(|cap| +// cap.iter().skip(1) +// .map(parse_int) +// .collect::>() +// .chunks(3) +// .map(|c| (c[0],c[1],c[2])) +// .map(|(h,m,s)| h*3600 + m*60 +s) +// .sum()) +// .collect::>(); + let mut vec = - hms.captures_iter(test) - .map(|cap| - cap.iter().skip(1) - .map(parse_int) - .collect::>() - .chunks(3) - .map(|c| (c[0],c[1],c[2])) - .map(|(h,m,s)| h*3600 + m*60 +s) - .sum()) + dig.split(test) + .map(|c| c.parse::().unwrap()) + .collect::>() + .chunks(3) + .map(|c| (c[0],c[1],c[2])) + .map(|(h,m,s)| h*3600 + m*60 +s) .collect::>(); vec.sort_unstable();