Saturday, April 6, 2013

project euler problem 305

Reflexive Position

This is the third time we see this number?
Champernowne’s constant. The first time we see it is in problem 40. If you take a look, you can feel the difference between the problems created in recent years and the problems created 10 years ago.

This problem is really interesting. It is easy to write a brute force code for small numbers, it is no-brainer! But for large numbers, it takes hours or days to get a correct answer.
From a long time ago, I knew how to solve it, but I do not want to write the complicated code to handle all situations. Several days ago, I decided to work on this problem in my spare time. It is really disturbing to find bugs here and there. Finally, I made it work. It takes less than 1 ms to get the answer! But I spent hours to make it correct.
The examples are very helpful if one does not write his own brute force code. 7780 is a very very important number. Even with this number, I still made some mistake in my code. But I watched those 3^n for a couple of minutes, then figured out why my answer is not correct. Another important number is 243, but it is small and easy to debug.

No comments:

Post a Comment