day3: code format

This commit is contained in:
Keenan Tims 2024-12-04 16:41:39 -08:00
parent 6a619d756f
commit e2cd0fe9cc
Signed by: ktims
GPG Key ID: 11230674D69038D4

View File

@ -43,7 +43,8 @@ fn problem1<T: BufRead>(input: Lines<T>) -> 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::<u64>().unwrap() * std::str::from_utf8(&m[2]).unwrap().parse::<u64>().unwrap();
sum += std::str::from_utf8(&m[1]).unwrap().parse::<u64>().unwrap()
* std::str::from_utf8(&m[2]).unwrap().parse::<u64>().unwrap();
}
}
sum
@ -60,7 +61,10 @@ fn problem2<T: BufRead>(input: Lines<T>) -> 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::<u64>().unwrap() * std::str::from_utf8(&m[3]).unwrap().parse::<u64>().unwrap(),
_ if do_mul => {
sum += std::str::from_utf8(&m[2]).unwrap().parse::<u64>().unwrap()
* std::str::from_utf8(&m[3]).unwrap().parse::<u64>().unwrap()
}
_ => {}
}
}