Coding style change for project_euler problem 36 and 35 (#3062)

* add problem url. Add typehint, default value and doctest

* run black

* add project url. add solution function for problem 35

* add space between imports on problem 35

* Update sol1.py

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
This commit is contained in:
Nelson Stoik
2020-10-08 21:05:13 -06:00
committed by GitHub
parent a3bbcd5f88
commit 1c0deb88ac
2 changed files with 36 additions and 7 deletions

View File

@ -1,4 +1,9 @@
"""
Project Euler Problem 36
https://projecteuler.net/problem=36
Problem Statement:
Double-base palindromes
Problem 36
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
@ -10,17 +15,28 @@ base 10 and base 2.
leading zeros.)
"""
from typing import Union
def is_palindrome(n):
def is_palindrome(n: Union[int, str]) -> bool:
"""
Return true if the input n is a palindrome.
Otherwise return false. n can be an integer or a string.
>>> is_palindrome(909)
True
>>> is_palindrome(908)
False
>>> is_palindrome('10101')
True
>>> is_palindrome('10111')
False
"""
n = str(n)
if n == n[::-1]:
return True
else:
return False
return True if n == n[::-1] else False
def solution(n):
def solution(n: int = 1000000):
"""Return the sum of all numbers, less than n , which are palindromic in
base 10 and base 2.