Function aoc::year2021::day18::add

source ยท
fn add(left: &[i32; 63], right: &[i32; 63]) -> [i32; 63]
Expand description

Add two snailfish numbers.

The initial step creates a new root node then makes the numbers the left and right children of this new root node, by copying the respective ranges of the implicit trees.

We can optimize the rules a little. This initial combination is the only time that more than one pair will be 4 levels deep simultaneously, so we can sweep from left to right on all possible leaf nodes in one pass.