Tuesday, March 12, 2013

project euler problem 036

Double-base palindromes

I do not have my original code, but I kept my isPalindromic() function. When I 
review this problem again, I found that my original method is too cumbersome.
I used vector to store all digits and then reverse the vector, finally compare all
digits.  This time I found a better method without the help of vector. It looks much better. This method also appeared in the discussion thread. 

I also realized that not all numbers need to be checked, only a small portion of 
the numbers need to be checked. It takes 4ms to find the answer.

Update: 

I rewrote the code again to create all decimal palindromic number in a different way which is a little bit easier to read than the old code, which handles odd number of digits and even number of digits a little bit differently.

No comments:

Post a Comment