advent_of_code_2024::day_22

Function populate_sequence_scores

source
fn populate_sequence_scores(
    sequence_scores: &mut Vec<usize>,
    seen: &mut Vec<usize>,
    seed: u64,
    id: usize,
)
Expand description

This finds the price of banana each sequence of four diffs that are present in the sequence will fetch. These are added to a mutable Vec indexed by the sequence_id, which is the previous four diffs packed into an int by shift_diff_into_sequence_id. Once a diff has been seen for each seed, future instances of that sequence are ignored. Again this is managed using a Vec that keeps track of the last id that wrote to a specific sequence_id, which is allocated once and passed in for performance.