Day 7 but math
This commit is contained in:
parent
df4a5a12d7
commit
8a61db424b
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user