mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Misc fixes
This commit is contained in:
@@ -32,7 +32,7 @@ fn compute_next<'a>(report: impl IntoIterator<Item = &'a i32>, deltas: &mut Vec<
|
|||||||
let mut delta = entry;
|
let mut delta = entry;
|
||||||
for prev_delta in &mut *deltas {
|
for prev_delta in &mut *deltas {
|
||||||
let prev = mem::replace(prev_delta, delta);
|
let prev = mem::replace(prev_delta, delta);
|
||||||
delta = delta - prev;
|
delta -= prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
if delta != 0 {
|
if delta != 0 {
|
||||||
@@ -40,7 +40,7 @@ fn compute_next<'a>(report: impl IntoIterator<Item = &'a i32>, deltas: &mut Vec<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deltas.iter().rev().fold(0, |c, d| c + d)
|
deltas.iter().rev().sum::<i32>()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn part1(input: &[u8]) -> anyhow::Result<String> {
|
pub fn part1(input: &[u8]) -> anyhow::Result<String> {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ pub fn part1(input: &[u8]) -> anyhow::Result<String> {
|
|||||||
|
|
||||||
let total: u64 = lines
|
let total: u64 = lines
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(line, groups)| number_ways(*line, groups))
|
.map(|(line, groups)| number_ways(line, groups))
|
||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
Ok(total.to_string())
|
Ok(total.to_string())
|
||||||
|
|||||||
Reference in New Issue
Block a user