My walkthrough style solutions for the first 100 ish problems in ProjectEuler.net. Everything was done in Python 3.13. I haven't found a non-spoilery way to get hints on Project Euler problems so I decided to make one! The steps to discovering the solution will be "spoiler-tagged" similarly to Discord or Reddit. Please use this if you ever need a nudge in the right direction on a Project Euler solution!
How do you write a non-spoilery hint system for Project Euler?
How would you make spoiler tags?
Try html.I need another hint!
Use the < details > tag and the < summary > tag.Final Solution (Gaurav Ramanan on Stack Overflow):
Edit this file and check the code.Runtime: n/a
(AN: Thanks for reading this!)
Problems are taken from https://projecteuler.net, a website full of mathy programming problems. The website asks not to spoil past the first 100 problems, so I will not be doing so.
There may be multiple solutions to each problem with varying levels of intuitive sense, speed, and elegance. My first priority is making these solutions a good resource for learning. This means including solutions that have one of the 3 qualities of intuitive sense, speed, and elegance. My second priority is including my own solution, the one that I used to find the solution the first time. If my solution does not have any of those three qualities, I will not prioritize including it as it has no educational value.
I will write explanations as if someone were reading them in numerical order. I briefly explain what a mod (%) is in the first problem, so I will not repeat that explanation in other problems. If I mention something you don't understand, try using a search engine. You could also consider looking through previous walkthroughs, but the spoiler-tagged format does not lend itself to skimming.
I will do my best to credit every idea in each walkthrough without making things cluttered. Some of the problems have "overviews" on Project Euler, which unlock after entering the numerical answer in the website. They are also done in a walkthrough format, but they do not have spoiler-tags. They deserve massive credit for inspiring the walkthough format as well as the solutions. In addition to myself and Project Euler overviews, I will get ideas from the Project Euler forum, blogs, other GitHub repos, etc. If sources other than myself are used, they will be credited. I did not copy and paste from them. I consolidate all solutions into the same format, using the same variable names, etc. to make it easier to follow for a reader.
I will try to include a runtime for every program in a walkthrough to compare speed. I am running these programs on a 2020 MacBook Air in PyCharm. I may also include a "Long Runtime" where the parameters of the problem are multiplied to amplify difference in runtime that may not be detected on small numbers.
These are my author's notes. I may have interjections about my personal process of learning that don't fit in with the walkthough, but I still feel compelled to include. I wish I could find a way to make them gray or otherwise less intrusive, but I can't figure anything out. Let me know if ther's a way to do that!
Some of these programs import the math module, but that's it. Since math is built in, there should be nothing to download. Simply copy + paste the code blocks into something that accepts Python code. Files are in md because they have to be spoiler tagged. Unfortunately, that means the code loses all the color-coding that happens when you use .py. Sorry.
In the future, I plan to add all 100 solutions. I've already finished a lot (but not all) of the 100 solutions, but I still need to rework them, add comments, and put them in the walkthrough format. Check the general TODO file and the specific TODO file for more information.
If you see a typo or a solution I missed, please let me know! Email: rachel.linlin.dai@gmail.com