I panicked when I took a look at the final puzzle for Advent of Code 2025 and saw that it asked for solutions to the “bin packing problem“. This problem is known to be NP-hard, where NP stands for Non-Polynomial, meaning that you can’t guarantee to be able to find a solution in a given amount of time. Deciding whether some number of items can fit into a given number of bins for any number of items, item sizes, and bins, is NP-complete, which means no general solution has been found, and if it were found, would transform many, many scientific fields.
So, this is the sort of problem Eric wants us to solve today. There are presents of odd sizes, and given some huge number of them — thousands of them — we need to figure out if there is some way they can be arranged in the given bin through rotation, flipping or both.
My first thought was to see if any of the pieces was larger than the bin in both dimensions, and my second thought was to add up the areas of all the pieces and compare it to the area of the bin. If it was greater, we knew they couldn’t all fit.
Unfortunately, the sample data proved why those two ideas wouldn’t be enough.

The explanation for Part 1 showed that it wasn’t possible to fit another seven area gift in the bin despite there being way more area than necessary.
I went to bed somewhat worried.
I woke up to this meme in the Advent of Code subreddit…

So I just implemented the couple of ideas I had before bed, and they worked, and that was all there was to it.
Merry Christmas and see you next year!







Leave a Reply