2019: day01: improve sub overflow handling
This commit is contained in:
parent
5e2fb25c94
commit
dd4e610324
|
@ -10,10 +10,7 @@ pub fn run() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fuel_needed(module_weight: u64) -> u64 {
|
fn fuel_needed(module_weight: u64) -> u64 {
|
||||||
match (module_weight / 3).checked_sub(2) {
|
(module_weight / 3).saturating_sub(2)
|
||||||
Some(f) => f,
|
|
||||||
None => 0,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part1(input: &str) -> Result<u64> {
|
fn part1(input: &str) -> Result<u64> {
|
||||||
|
|
Loading…
Reference in a new issue