So I’m geeking around the internet, like I usually do, when I stumble upon this awesome site. Project Euler! Pretty much, its a set of math questions that are ONLY solvable with a computer. So what does it mean for a young, industrious programmer like myself? Fun!
There’s 229 problems, and I’ve solved 27 so far… as you can see, I’ve got a long way to go. Some of them are easy:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Fairly easy to solve. Find all multiples of 3 or 5 and sum them up. Done. Now lets examine another problem:
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …
Find the sum of all the even-valued terms in the sequence which do not exceed four million.
This is where it gets complicated. The Fibonacci sequence actually grows pretty quick, which means the number will actually in the computer’s buffer, resulting in an “out of range” exception pretty quickly. Which means you can’t do a simple Fibonacci sequence linearly.
As the problems get more complicated, the chance that you can brute-force the answers become less likely. One of my favorite questions was the monopoly one:
In the game, Monopoly, find the three most popular squares when using two 4-sided dice.
I actually built a simulator to solve it, where I could change the dice easily. So I ran it for a 6-sided dice (like the ones we usually use), and found the following stats (10 million rolls):
1. Jail - 622228 2. Illinois Ave - 318336 3. New York Ave - 309739 4. GO - 308705 5. B&O Railroad - 307718 6. Reading Railroad - 297163 7. Tennessee Ave - 293212 8. Pennsylvania Railroad - 291143 9. Free Parking - 287501 10. Kentucky Ave - 283870 11. Water Works - 279720 12. St. James Place - 279563 13. Indiana Ave - 273179 14. Atlantic Ave - 269697 15. St Charles Place - 269678 16. Pacific Ave - 268251 17. Ventnor Ave - 267982 18. Boardwalk - 262216 19. North Carolina Ave - 261937 20. Electric Company - 259929 21. Marvin Gardens - 258568 22. Community Chest 2 - 258082 23. Pennsylvania Ave - 250309 24. Virginia Avenue - 246854 25. Short line - 242476 26. Community Chest 3 - 238379 27. States Ave - 237184 28. Vermont Ave - 232893 29. Income Tax 1 - 231599 30. Connecticut Ave - 230336 31. Oriental Ave - 226835 32. Park Place - 219057 33. Luxury Tax - 218509 34. Baltic Ave - 216265 35. Mediterranean Ave - 213695 36. Community Chest 1 - 189488 37. Chance 2 - 103436 38. Chance 1 - 87370 39. Chance 3 - 86898 40. Go To Jail - 0
Although, I may have to fix it up. From experience, I know going to jail shouldn’t be that low! All in all, these questions are a great way to practise programming when working with a new language. So try it out, you might enjoy it as much as I have.


2 Users Commented In This Post
Subscribe To This Post Comment Rss Or TrackBack URL