1
0

clean day09
Some checks failed
Build and test / test (push) Failing after 1m49s

This commit is contained in:
xeals 2023-12-09 20:46:40 +11:00
parent 9b8ae4f350
commit b5583ca46e
Signed by: xeals
SSH Key Fingerprint: SHA256:53xHRPqZPQewIgPNiVQ96gm8O4xBVzaxNj1LCSJpTf4

View File

@ -46,14 +46,10 @@ fn solve(alloc: mem.Allocator, input: []const u8) !Solution {
// Extrapolate // Extrapolate
var next: isize = 0; var next: isize = 0;
var prev: isize = 0; var prev: isize = 0;
for (seqs.items) |seq| {
next += seq[seq.len - 1];
}
for (0..seqs.items.len) |i| { for (0..seqs.items.len) |i| {
prev = seqs.items[seqs.items.len - i - 1][0] - prev; const seq = seqs.items[seqs.items.len - i - 1];
} prev = seq[0] - prev;
for (seqs.items) |seq| { next += seq[seq.len - 1];
// Clean up
alloc.free(seq); alloc.free(seq);
} }
prev_sum += prev; prev_sum += prev;