From 7bc3e742028d0d5bc1199ba53869f26876b2fd84 Mon Sep 17 00:00:00 2001 From: steven-y-e Date: Tue, 1 Aug 2023 21:12:26 -0400 Subject: [PATCH] feat(solution): problem #36 --- solutions/036/doublebasepalindromes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 solutions/036/doublebasepalindromes.py diff --git a/solutions/036/doublebasepalindromes.py b/solutions/036/doublebasepalindromes.py new file mode 100644 index 0000000..fcdfbf7 --- /dev/null +++ b/solutions/036/doublebasepalindromes.py @@ -0,0 +1,14 @@ +def is_palindrome(maybePalindrome): + for i in (range(0, int(len(maybePalindrome)/2))): + if maybePalindrome[i] != maybePalindrome[len(maybePalindrome) - i - 1]: + return False + return True + +palindromeSum = 0 + +for i in range(1000000): + if is_palindrome(str(i)) and is_palindrome(str(bin(i))[2:]): + palindromeSum += i + print(palindromeSum) + +print("The sum of all double base palindrome numbers below 1000000 is: ", palindromeSum)