The elves are in luck: the cafeteria business continues to grow. Too bad they made a bit of confusion with the boxes. They struggle to figure out how to box all shipments without wasting cardboard. The Elf Post Service 📯 (ECS) has several formats to choose from. Today’s Dev Advent puzzle is about this.

The puzzle: Optimizing shipping 📦

Today’s problem concerns geometry: it is a question of understanding whether one box can fit into another. It is not enough to measure the length of the individual corners, a box can also be rotated to make it fit.

The solution is trivial and does not require explanations:

I have looked for a generic formula to achieve this in a more elegant way but I have not found anything better. And with only 3 dimensions, a manual formula is enough.

There is, however, one interesting thing. I renamed the variables during the object destructuring operation. Just add the name of the new variable after the name of the original one:

The example above is not mine, it is from Paul Vaneveld. I found it in an interesting article published on Medium: 7 Little-Known Techniques to Improve Your JavaScript.

Well, that’s all for today.