Function aoc::year2021::day23::organize

source ·
fn organize(burrow: Burrow) -> usize
Expand description

A* search over all possible burrow states until we find the lowest cost to organize.

Each state is processed in one of two phases, “condense” or “expand”.

In condense, ampihpods move from the hallway or another burrow directly to their home burrow. Multiple moves are combined if possible and each burrow is tried from left to right. In terms of energy this is always an optimal move.

If no moves to home burrows are possible then the expand phase moves amphipods into the hallway.