I keep my solutions to Project Euler problems on this site. I generally solve the problems in either Python, C, or Cython, and I usually start within the Sage Notebook with Python or Cython. I’m starting to add some Clojure solutions as well.
In some cases, I’ve attempted to optimize the solution – starting with a naive or simplistic approach and leading to an improved solution. In other cases, the problem doesn’t seem interesting enough or optimization isn’t a huge concern. In still other cases, clarity of the code requires some runtime compromise. In many of the problems, especially when a more optimal solution isn’t obvious, I try to explain the approach.
My main goals here are twofold: (1): I like teaching and I want to help others learn. I’m entirely aware that some people will find this site, email me, and ask me to take solutions down. Sorry – that isn’t going to happen. If someone wants to find solutions and cheat, they will. Get over that fact. If, on the other hand, a potentially smaller group of coders is interested in solutions and optimizations, then that is who these solutions are aimed at. And, every once in a while someone will email me with an optimization to my own solutions – which I think is awesome. And (2): This is how I learn – by forcing myself to explain and teach and clarify.
I used to maintain a list here of timings for the individual problems. I removed that after getting a new laptop and realizing that my previous timings were no longer consistent with my development environment. The individual problem posts will still contain runtime records, but you’re encouraged to use the code yourself and see how things compare to your own solutions – as running on different hardware will clearly provide different results.
Happy problem solving and coding!
Problem 1 (Python, Clojure)
Problem 2 (Sage, Python, Cython)
Problem 3 (Sage, Python, Cython, C)
Problem 4 (Python, Cython, C)
Problem 5 (Python)
Problem 6 (Python, Cython)
Problem 7 (Python, Cython)
Problem 8 (Python)
Problem 9 (Python, Cython)
Problem 10 (Python, Cython)
Problem 11 (Python)
Problem 12 (Sage, Python, Cython)
Problem 13 (Python)
Problem 14 (Python, Cython, C)
Problem 15 (Python, Cython)
Problem 16 (Sage, Python, Cython)
Problem 17 (Python)
Problem 18 (Python)
Problem 19 (Python, Cython, Sage)
Problem 20 (Sage, Python)
Problem 21 (Python, Cython, C, C/OpenMP)
Problem 27 (Sage, Python, Cython)
Problem 67 (Python)
Problem 49 (Sage)
Problem 288 (Python)