Module day24

Source
Expand description

§It Hangs in the Balance

To simplify things assumes that the remaining items after the first best combination is found can be split evenly.

Sorts the weights in ascending order, then tries combinations of increasing size until a match in found. This will be the answer since the package count is the smallest and the quantum entaglement will also be the lowest.

Functions§

combinations 🔒
Breadth first search over all possible package combinations as we want the fewest possible packages that sum to the target weight. Uses a bitmask as a set for each package combination.
parse
part1
part2