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