Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Integer Palindrome by freeman_lex
def int_palindrome(number: int, B: int) -> bool:
rev = norm = power = 0
while number:
number, b = divmod(number, B)
rev = rev * 10 + b
norm = b * 10**power + norm
power += 1
return rev == norm
print("Example:")
print(int_palindrome(455, 2))
assert int_palindrome(6, 2) == False
assert int_palindrome(34, 2) == False
assert int_palindrome(455, 2) == True
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 18, 2022
Comments: