Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asuka-mirai/df0b7e656ea538c76310b46167423606 to your computer and use it in GitHub Desktop.
Save asuka-mirai/df0b7e656ea538c76310b46167423606 to your computer and use it in GitHub Desktop.
Base_Exchange_Palindrome
num = 10
judge = False
try:
while True:
base = input().split(',')
except EOFError:
pass
base_01 = int(base[0])
base_02 = int(base[1])
def radix_convert(number, radix):
s = []
while number>0:
s.append(number%radix)
number = number//radix
return s[::-1]
while judge == False:
num_base01 = radix_convert(num, base_01)
num_base02 = radix_convert(num, base_02)
if num_base01 != num_base01[::-1] or num_base02 != num_base02[::-1]:
judge = False
num += 1
else:
judge = True
print(num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment