From e2cd0fe9cc92745a2b40e7d570cd9eae584a53e7 Mon Sep 17 00:00:00 2001 From: Keenan Tims Date: Wed, 4 Dec 2024 16:41:39 -0800 Subject: [PATCH] day3: code format --- 3/src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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() + } _ => {} } }