diff options
author | kdx <kikoodx@paranoici.org> | 2023-12-09 23:36:10 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-12-09 23:36:10 +0100 |
commit | fc51b15375344a73cb835c98e2fb7ae04dafbf44 (patch) | |
tree | 198e9240332145cd7a99fb525732d7da5878bbe6 | |
parent | beea2fbfecb400991c467354272c1e99d12a2540 (diff) | |
download | aoc23-fc51b15375344a73cb835c98e2fb7ae04dafbf44.tar.gz |
09 rust
-rw-r--r-- | 09/rust/src/main.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/09/rust/src/main.rs b/09/rust/src/main.rs index 537d38a..f1a52cb 100644 --- a/09/rust/src/main.rs +++ b/09/rust/src/main.rs @@ -32,15 +32,14 @@ fn main() { } } - history.last_mut().unwrap().push(0); + history.last_mut().unwrap().insert(0, 0); for i in 1..history.len() { let i = history.len() - 1 - i; - let idx = history[i].len() - 1; - let v = history[i][idx] + history[i + 1][idx]; - history[i].push(v); + let v = history[i][0] - history[i + 1][0]; + history[i].insert(0, v); } - sum += history[0].last().unwrap(); + sum += history[0][0]; } println!("{sum}"); } |