Successfully finished the second puzzle.
Took me a bit worrying what "and at most two of the Elves will be carrying any other item type" meant in the task text while my grouping loop was broken and skipping a rucksack every fourth rucksack while doing the group. Yikes.
Caught the error before trying a result though thanks to exceptions when things go wrong!