From b36423bd9c05dc0d50bfc81d03c3ee6449ef6e14 Mon Sep 17 00:00:00 2001 From: daviddoji Date: Fri, 30 Sep 2022 21:07:28 +0200 Subject: [PATCH] Adopted new convention from template --- src/Python/Problems001-050/Problem036.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Python/Problems001-050/Problem036.py b/src/Python/Problems001-050/Problem036.py index 4043417..de8b6d0 100644 --- a/src/Python/Problems001-050/Problem036.py +++ b/src/Python/Problems001-050/Problem036.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Created on 08 Apr 2021 @@ -11,9 +11,11 @@ https://projecteuler.net/problem=36 from utils import timeit + def is_palidrome(num): return str(num) == str(num)[::-1] + @timeit("Problem 36") def compute(): """ @@ -23,13 +25,14 @@ def compute(): Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2. """ + ans = 0 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 + return ans if __name__ == "__main__": - - print(f"Result for Problem 36: {compute()}") \ No newline at end of file + print(f"Result for Problem 36 is {compute()}")