diff --git a/3/src/main.rs b/3/src/main.rs index 3b5af1c..838e5a2 100644 --- a/3/src/main.rs +++ b/3/src/main.rs @@ -43,7 +43,8 @@ fn problem1(input: Lines) -> u64 { for line in input.map(|i| i.unwrap()) { let line = line.as_bytes(); for m in re.captures_iter(line) { - sum += std::str::from_utf8(&m[1]).unwrap().parse::().unwrap() * std::str::from_utf8(&m[2]).unwrap().parse::().unwrap(); + sum += std::str::from_utf8(&m[1]).unwrap().parse::().unwrap() + * std::str::from_utf8(&m[2]).unwrap().parse::().unwrap(); } } sum @@ -60,7 +61,10 @@ fn problem2(input: Lines) -> u64 { match std::str::from_utf8(&m[1]).unwrap() { "do()" => do_mul = true, "don't()" => do_mul = false, - _ if do_mul => sum += std::str::from_utf8(&m[2]).unwrap().parse::().unwrap() * std::str::from_utf8(&m[3]).unwrap().parse::().unwrap(), + _ if do_mul => { + sum += std::str::from_utf8(&m[2]).unwrap().parse::().unwrap() + * std::str::from_utf8(&m[3]).unwrap().parse::().unwrap() + } _ => {} } }