Day 7 but math

This commit is contained in:
StNicolay 2024-12-07 10:58:10 +03:00
parent df4a5a12d7
commit 8a61db424b
Signed by: StNicolay
GPG Key ID: 9693D04DCD962B0D

View File

@ -10,13 +10,16 @@ enum Operation {
} }
impl Operation { impl Operation {
#[allow(clippy::pedantic)]
fn apply(self, a: u64, b: u64) -> u64 { fn apply(self, a: u64, b: u64) -> u64 {
match self { match self {
Self::Add => a + b, Self::Add => a + b,
Self::Mul => a * b, Self::Mul => a * b,
Self::Concentration => { Self::Concentration => {
let val = format!("{a}{b}"); if b == 0 {
val.parse().unwrap() return a * 10;
}
(a * 10_u64.pow((b as f64).log10() as u32 + 1)) + b
} }
} }
} }