Project Euler is a series of challenging mathematical/computer programming problems that require more than just mathematical insights to solve. I’ve enjoyed solving Project Euler problems since 2012, alternating droughts with periods of problem solving. Though now that I’ve solved 131 problems those I find easy are mostly behind me and each problem takes more time to solve with an increasing frequency of problems I’ve attempted but failed to solve. So I put my working code in a git branch, create a GitHub issue to track my state, and try again at a later date. Maybe in the future I’ll have learned the concepts necessary to solve the problem.

And much of the fun of solving euler problems is researching and discovering those mathematics insights and many of them involve combinatorics. In combinatorics, the twelvefold way is a systematic classification of 12 related enumerative problems concerning two finite sets, which include the classical problems of counting permutations, combinations, multisets, and partitions either of a set or of a number. I’ve created for myself a cheat sheet for solving Project Euler problems using the twelvefold way which I’m providing here. I’ve compiled this information from Stanley (Enumerative Combinatorics, Volume 1, 1997) by way of Knuth (The Art of Computer Programming: Volume 4a, Combinatorial Algorithms, Part 1, 2011) and Wikipedia, et al.



  1. Stanley, R. P. (1997). Enumerative Combinatorics, Volume 1 (Second, Vol. 1). Cambridge University Press.
  2. Knuth, D. E. (2011). The Art of Computer Programming: Volume 4a, Combinatorial Algorithms, Part 1. Addison-Wesley.