Advent of Code: Day 24
It Hangs in the Balance

First puzzle

In this puzzle, we are going to organize a set of packages into three groups. The only important characteristic of the package is its weight, and the set of weights is the puzzle input. The organization of the packages needs to follow these rules:

Very simple input parsing:

I was struggling with this problem for a while, and couldn’t find an elegant solution. There was something about the approach I was taking leading to a calculating all the possible combinations. It was a dead end, and I couldn’t move out of it. The help came from Yan Cui (blog post)[]. We didn’t need all the combinations; we need to find the weight of the groups by dividing the total package sum into the group size, and then find the smaller set possible with that weight. Once we have that, we need to find the calculate the set “quantum entanglement”, and locate the minimum:

Second puzzle

The second puzzle is the same, but we need to organize the packages into four groups instead of three:

You can find this code along with my input and puzzle answers at here.

Written by Darien Martinez Torres on 24 March 2016