I learned to program by solving Project Euler problems. It went like this:
- I had already worked through the exercises in the first few chapters of SICP. I'd tried programming many times. And so I was able to attack the first few Project Euler problems with confidence.
- I made surprisingly steady progress on the next twenty or so. If you look at the Date Modified column in the folder where I keep my solutions, you can see that in the early days I was running at a clip of one or two problems per day.
- I remember I spent five or six days struggling with a single problem. I think it might have been problem #23. It was around May 31st, 2007. I was in Montreal for my brother's birthday. On that exact day, I can see now by searching Gmail, I had received a notice from my university informing me that I was on academic probation; I had failed at least one class. I hadn't yet told my parents of my terrible grades.
- And suddenly Project Euler had become a slog. I was hitting a wall. I remember it gave me this terrible feeling of despair. I didn't like how I had quit so many things in my life; here I was doing it again. I had this pattern: I'd excitedly start something, I'd see a lot of quick progress, and then I'd hit that stretch of difficulty that divides amateurs from experts -- the pons asinorum that turns hopeful young men into quitters -- and I'd move on to something else.
- The difference this time around, interestingly enough, was that I had just read Seth Godin's The Dip: A Little Book That Teaches You When to Quit (and When to Stick). That book made me recognize the pattern. I saw myself hitting a wall. It was very clear: where before I'd taken a few hours to solve a problem, maybe an afternoon, here I was taking several days. If you charted my progress you'd vividly see the dip. And I remember deciding this time to fight.
- The frustrating and beautiful thing about Project Euler problems is that the solution is always a single integer. No one tells you whether you're "close": You have either solved the problem or you haven't. And there was always this hopeful pause after you submitted a possible solution, before the next page loaded. You'd see one of two images. More often than not it was a big red X.
- I can't tell you how much it meant to me to finally see that one green check mark in Montreal.
- I went on to solve 142 Project Euler problems.
In this repository I've collected as many as the solutions I have on hand. I believe I stopped storing them in this folder after a while.
The problems do become steadily more involved. There was a time shortly after college where I'd spend at least an hour a day -- often three or four -- chipping away at some high-numbered problem. Often you'd need a mathematical insight to solve them. But by then I'd gotten good at fighting. I'd gotten sort of relentless.