From 8a61db424bb56fcd763a05d04bb1912527643673 Mon Sep 17 00:00:00 2001 From: StNicolay Date: Sat, 7 Dec 2024 10:58:10 +0300 Subject: [PATCH] Day 7 but math --- src/day7.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/day7.rs b/src/day7.rs index a65cd85..6a9a440 100644 --- a/src/day7.rs +++ b/src/day7.rs @@ -10,13 +10,16 @@ enum Operation { } impl Operation { + #[allow(clippy::pedantic)] fn apply(self, a: u64, b: u64) -> u64 { match self { Self::Add => a + b, Self::Mul => a * b, Self::Concentration => { - let val = format!("{a}{b}"); - val.parse().unwrap() + if b == 0 { + return a * 10; + } + (a * 10_u64.pow((b as f64).log10() as u32 + 1)) + b } } }