In day 17 of the Advent of Code challenge, we have 150 litres of eggnog and need to work out all the ways of using our various containers to store that amount. The brute force solution to this problem involves checking the “power set” of our containers, but the solution I show in C# and F# performs much faster than this.

Here’s my C# code, which uses a recursive function called Distribute to return all the combinations of containers whose sizes add up to exactly 150

About Mark Heath

I'm a Microsoft MVP and software developer based in Southampton, England, currently working as a Software Architect for NICE Systems. I create courses for Pluralsight and am the author of several open source libraries. I currently specialize in architecting Azure based systems and audio programming. You can find me on: