We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
For those who are curious, my solution takes the following points into account:
Use combinations and permutations to generate palindromes in decimal base.
Consider when the number of digits is odd.
Quit as soon as possible if a number is not palindrome, instead of comparing the whole string.
Think about the relationship between the base K and the first digit (or the last digit as well). 0 is not possible for any base. 2 is not possible for binary, 8 is not possible for octal...etc.
That way I could pass any test case up to N=10^10.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #36: Double-base palindromes
You are viewing a single comment's thread. Return to all comments →
For those who are curious, my solution takes the following points into account:
K
and the first digit (or the last digit as well).0
is not possible for any base.2
is not possible for binary,8
is not possible for octal...etc.That way I could pass any test case up to N=10^10.