Adopted new convention from template

This commit is contained in:
David Doblas Jiménez 2022-09-30 21:07:28 +02:00
parent a0a7a8d34d
commit b36423bd9c

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python
""" """
Created on 08 Apr 2021 Created on 08 Apr 2021
@ -11,9 +11,11 @@ https://projecteuler.net/problem=36
from utils import timeit from utils import timeit
def is_palidrome(num): def is_palidrome(num):
return str(num) == str(num)[::-1] return str(num) == str(num)[::-1]
@timeit("Problem 36") @timeit("Problem 36")
def compute(): def compute():
""" """
@ -23,13 +25,14 @@ def compute():
Find the sum of all numbers, less than one million, which are palindromic Find the sum of all numbers, less than one million, which are palindromic
in base 10 and base 2. in base 10 and base 2.
""" """
ans = 0 ans = 0
for i in range(1, 1_000_001, 2): for i in range(1, 1_000_001, 2):
if is_palidrome(i) and is_palidrome(bin(i)[2:]): if is_palidrome(i) and is_palidrome(bin(i)[2:]):
ans += i ans += i
return ans return ans
if __name__ == "__main__": if __name__ == "__main__":
print(f"Result for Problem 36 is {compute()}")
print(f"Result for Problem 36: {compute()}")