published: 2011/07/09. tags: project euler, fastest solvers

Twenty20

It's always possible to learn something new

It's been a little over two years since I started Project Euler. Along the way, I reached the current highest level, Veterans. I already wrote about my experience of reaching the Legend level sometime back. At the time I reached the Legend status, I had about 30 or so unsolved problems. By the time I reached the Veterans, that number has reduced further down to 12. The latest season (2010-2011) just ended at 344 problems, I only have one unsolved problem for the season and a total of 6.

The purpose of this article is to go over my journey further since I touched that 250 to reach the Legend status.

On the Veterans Level

Unlike the previous levels, the Veterans level focuses on speed. After a person reaches this level, it is no longer about quantity but speed. It is assumed that a person who managed to reach this level can more or less solve all the problems eventually. So, the members in this group are differentiated based on speed. The first 20 solvers are tracked and listed for each problem. Also, the veterans are listed based on their date of registration and not based on when they became veterans or their name. Part of the reason for changing it to this model is to discourage cheating. I think for some people it is so important they are in par or above their friends that they would do whatever it takes to show 100%. But for Veterans, it's no longer possible to see how many problems they actually completed. It's possible to only know that they completed at least 300. Because of this, even the profile page has been made private. So, why exactly all these types of changes done for the latest level? It is to discourage cheating.

On cheating on Project Euler

What exactly is considered cheating? Some one asked this question in the forum and also there is a poll. It may sound like a stupid question but actually not. For example, If any of them is considered cheating, I did a fair share of it. I was 2nd for Problem 304 because I used PARI/GP and it's built-in functions. I managed to solve Problem 258 based on a private forum post in Problem 304. I did a lot of online research for Problem 341 and Problem 344.

Actually some people want to collaborate to solve these problems. This is understandable, a lot of complex projects in real life (software or otherwise) are achieved by collaboration. But at the same time, the type of complexity in Project Euler is different. Surprisingly, the length of the code to solve the problem itself is never really large. Most of them can be solved with 100 lines of C code and rarely more than a few hundred. So, the complexity is really to do with understanding of the basic concepts and applying them in the right way. Take Problem 344 for example. One would realize after solving, that it's a combination of similar problems for which solutions are available online and a bit of clever dynamic programming. The later part, once figured out, is not really complex in terms of the number of lines of code. But if this part is collaborated and the answer is obtained, then IMHO the real thrill of solving it is lost. But if one were to say that it's worth it as it helps one learn something complex. Fine, as long as the person doesn't submit the answer and increase the solved problems count. But the problem for some is that they want to access the private forums which are accessible only when a problem's answer is submitted.

I think rather than worrying about who is cheating and not, it's better for each person to focus on what they want out of Project Euler. For me, I like Project Euler because

On Speed

I admit I am not one of those few people on Project Euler who can solve any problem that comes along their way. There are a few people who solved two completely unrelated problems that came on the same day in under 30 minutes while I struggled to solve them even after a few days. There are a few reasons why I usually am not in the top 20. Inspite of all the valid and lame reasons I gave above, I did manage to be in the top 20 a few times. This happens mostly for those few problems that don't get solved by 20 people in the first 1 day. For example, Problem 328 took me 3 days, 10 hours, 32 minutes and 24 seconds and I still managed to be the 17th person to solve it. It's really frustrating sometimes when I miss out to be in the top 20 by just a few submissions especially for tough problems. This happened multiple times for me and I felt the pinch mostly for Problem 331 (22nd I think) and Problem 344 (23rd). As per the public forums, they are supposed to track more than top 20 people in the future. But what should be that number? In my opinion, it should not be a fixed number, but depend on the complexity of the problem. For problems where there are more than 50 solutions within a day, tracking more than 20 doesn't really matter. But if it takes a few days to fill up the top 20, then perhaps going even up to top 50 may be good.

On Yet Another Speed

One of the goals when solving the Project Euler problems is to come up with a solution, not just fast, but that runs fast. I noticed that ever since the Veterans level has been introduced and the emphasis was given to the first 20 solvers, there have been submissions where the solutions were sub-optimal. Just to be clear, these people who submitted such solutions are actually very capable. But because of the race to be in the top 20 fastest solvers, they first provide the answer and sometimes go back and optimize or come up with an even clever solution.

The emphasis on the speed of the program has always been there. It's expected that the programs typically take no more than 1 minute to solve the problem. Of course, which programming language is used has a definite impact. Also, though the goal is to do it within a minute, there are times I come up with a solution for a complex problem that runs in a few seconds in a -O3 optimized C++ code only to find a sub-second solution even in an interpreted language. It makes me wonder that all those benchmarking that are published comparing programming languages is almost useless since time and again I have noticed that a very clever algorithm outsmarting the heavily optimized executable by a large difference. I must admit, I make use of the convenience of PARI/GP usually for number theory related problems and matrix operations and as a result end up with solutions that sometimes don't meet the one minute rule. I am fine with this because I kind of know that the underlying algorithm is very good and if implemented in a different programming language it would run fast (Problem 280, for example was done in PARI/GP and slow).

On Twenty20

If there are only 20 fastest solvers, then why am I calling this article Twenty20? Yeah, I am a cricket fan, but that's not the reason for calling this Twenty20. While the number of problems solved is no longer available for Veterans, the distribution of how many people solved how many problems is available in the public forum posted periodically. I was the 94th person to reach the Veterans level and at that time I still had 12 unsolved problems. At present the count is down to 6 unsolved problems for me. Also, the difficulty of some of the problems in this season seems to be lot more than the previous problems. As a result, based on the distribution of solvers, at the end of the latest season, I am in the top 20 people. So, while I barely manage to be in to top 20 for speed, I seem to be in the top 20 based on the total number of problems solved. But probably this is not accurate because

Ponder That

Personal Benefits

Here are some of the benefits that I got along the journey for the last two levels
  1. More and more confidence. When I started off on Project Euler, I wasn't sure I would reach Legends level because my academic background wasn't either computer science or mathematics. However, since I have been exposed to programming since 1991 and I had the pleasure of taking Introduction To Algorithms at MIT during my graduate studies, I do have some relevant background. So, as I put in more time thinking about these problems in solving them, my knowledge and confidence certainly have increased.
  2. Some people think and act as if they are the smartest people in the world based on what they work on. But now I can tell with confidence, it's not what a person is working on but what the person can really work on that determines.
  3. Determination and concentration. Even prior to working on Project Euler, I did have a lot of determination and concentration when required. Project Euler gives a chance to put those into practice more often.

© 2011 Dirisala.Net/articles