Skip to content

Instantly share code, notes, and snippets.

@ricbit
Created March 31, 2020 17:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ricbit/6bb4b5c9dfbff036d374f0612b761d46 to your computer and use it in GitHub Desktop.
def to_base(n, base):
ans = []
while n > 0:
ans.append(n % base)
n //= base
return ans
def is_palin(n):
return n == n[::-1]
for age in range(1, 120):
for base in range(2, age):
ageb = to_base(age, base)
yearb = to_base(age + 1976, base ** 2)
if is_palin(ageb) and is_palin(yearb) and len(yearb) > 1:
print(age, base, ageb, yearb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment