Created
March 31, 2020 17:53
-
-
Save ricbit/6bb4b5c9dfbff036d374f0612b761d46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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