Project Euler Level 2

June 20, 2021

Project Euler is a site with a long list of problems to solve. The problems usually focus on some mathematical idea. Most people use a programming language to solve them, but some try with just a pencil and paper.

When I first fell in love with programming, I didn't know what to do with it, so I started trying to solve these problems. All I knew was a little C++, so I used that until a friend introduced me to Python. I also had no sense of runtime complexity, so it was surprising when my code would seemingly just hang instead of producing an answer.

My limited skills allowed me to solve some problems, and the fake internet points felt rewarding. The site also let me know that I had much left to learn since the list of problems was long and mostly unapproachable.

More recently, I returned to the site and was able to solve another ~20 problems in JavaScript without too much effort. Years ago, those problems probably felt out of reach. Of course I know I've gotten more capable since those early days, but it was nice to really feel it.

brandly on Project Euler

Solving 50 problems advanced me to Level 2! As of this moment, I've solved 52 problems which puts me in the 95th percentile of all registered users who've solved at least one problem. If you're logged in, you can view those stats here.

Some people use these kinds of problems to explore a new language, but my recent solutions were written in JavaScript, a language I know well. Even then, BigInts aren't very familiar to me, but I needed them occasionally in this context. But for most problems up to this point, basic floating-point numbers and data structures like objects, arrays, and sets are enough to get the job done.

These solutions should only take a moment to run through some combination of mathematical insight and using the right data structures, but I wrote one solution that took ~10 minutes to run. When that problem was written in 2007, the brute force solution would've been further out of reach, but now I can just grind out an answer in JS on a laptop.

Each problem has a difficulty rating. I'm not sure how they're calculated, but most of the problems I've solved have the lowest difficulty rating of 5%. The hardest one of I've solved is titled Su Doku and has a difficulty of 25%. I wrote a sudoku solver a while back, so all that was left for my solution was some basic glue code.

If you also like solving little puzzles, give Project Euler a try. Rosalind is another list of problems focused on bioinformatics, and Advent of Code is a nice, seasonal one. They're all pretty fun and might expose you to some new ideas.