A few days before I started the Flatiron School, Dave introduced me to Project Euler.
This is a website with hundreds of math problems that you need to solve by building a comptuer program. It is named after the 18th century Swiss mathemetician Leonhard Euler, who according to wikipedia is “one of the most prolific mathematicians ever”.
While there is some disagreement over how to pronounce Euler (some say ‘oiler’, some say ‘youler’), there is a broad consensus that this is a great way to learn how to become a better programmer. However many people are intimidated by this website, since it involves math.
I’ve been going through these problems over the last few weeks and have a git repository of my work. I can say that yes it is a bit challenging, but that you learn so much that you should stop worrying, and just start doing the problems. I’ll take the problem I finished last night, and use it to show what I’ve been able to learn.
1 2 3 4 

1. You Get A Math Refresher
Instead of being intimidated by hard math concepts, just view it as an opportunity to hone your math skills! Math was always one of my favotite subjects in school because it made sense, and if I worked hard enough I could find a definitive answer. Perhaps I’m a bit unique in this, but doing math problems is really fun for me. For this problem, I had to jog my memory about prime numbers. I remembered that prime numbers were numbers greater than 1 that had no other factors besides 1 and itself. Not anything enlightening, but good to know I still remember middle school math concepts.
2. You Are Forced To Break Down Problems
I then realized I needed to break this problem down into many smaller problems. This has been one of the most critical skills I’ve developed while at the Flatiron School. If you are unable to take a big problem and break it down into smaller subproblems, you won’t be able to do much of anything in programming. Project Euler has been one of the best resources I’ve found to practice doign this.
Here is how I broke down problem 10.
1 2 

Once I started the first step I realized I could break it down further.
1 2 3 

For the second step, I already knew that what I was doing (taking an array and adding it together) perfectly fit the pattern of reduce, and so didn’t need to further break it down. Avi should be proud that I’ve developed this kind of intuition.
3. You Learn How to Refactor
I ended up with some code that worked (the answer is 142,913,828,922), but was extremely slow
1 2 3 4 5 6 7 8 9 10 

At this point, I let myself go on the internet and try to find a way to refactor. I stumbled upon the ruby prime guide and realized that the prime module had more functionality that I could use to speed up my program. Here is my new code that I made after doing that research:
1 2 3 4 5 6 

It turns out that Prime is a class that is basically an array of every prime number. Since I am now only iterating over prime numbers as opposed to all numbers, my program went considerably faster  running in about half a minute as opposed to the several minutes it took to run the original.
Refactoring is a concept that some people get intimidated by, but by starting small and taking baby steps you can build up confidence to take on more challenging problems like refactoring huge controllers in rails.
So to all those on the fence about trying Project Euler  I say GO DO IT!