From 0f47b07747866443b9b8121336959aeef7870660 Mon Sep 17 00:00:00 2001 From: shellhub Date: Tue, 15 Sep 2020 01:13:06 +0800 Subject: [PATCH 1/4] Updated problem_04 in project_euler --- project_euler/problem_04/sol1.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/project_euler/problem_04/sol1.py b/project_euler/problem_04/sol1.py index 599345b5ab79..f3e2afb250c4 100644 --- a/project_euler/problem_04/sol1.py +++ b/project_euler/problem_04/sol1.py @@ -18,25 +18,34 @@ def solution(n): 29992 >>> solution(40000) 39893 + >>> solution(10000) + Traceback (most recent call last): + ... + ValueError: It is larger number than our acceptable range. """ # fetches the next number - for number in range(n - 1, 10000, -1): + for number in range(n - 1, 9999, -1): # converts number into string. - strNumber = str(number) + str_number = str(number) - # checks whether 'strNumber' is a palindrome. - if strNumber == strNumber[::-1]: + # checks whether 'str_number' is a palindrome. + if str_number == str_number[::-1]: divisor = 999 # if 'number' is a product of two 3-digit numbers # then number is the answer otherwise fetch next number. while divisor != 99: - if (number % divisor == 0) and (len(str(int(number / divisor))) == 3): + if (number % divisor == 0) and (len(str(number // divisor)) == 3): return number divisor -= 1 + raise ValueError("It is larger number than our acceptable range.") if __name__ == "__main__": - print(solution(int(input().strip()))) + import doctest + + doctest.testmod() + + print(solution(int(input().strip()))) \ No newline at end of file From bd2ba03787e941e15ed85b950e3ad72e0335529e Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Mon, 14 Sep 2020 17:49:42 +0000 Subject: [PATCH 2/4] fixup! Format Python code with psf/black push --- project_euler/problem_04/sol1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_euler/problem_04/sol1.py b/project_euler/problem_04/sol1.py index f3e2afb250c4..5708aceff060 100644 --- a/project_euler/problem_04/sol1.py +++ b/project_euler/problem_04/sol1.py @@ -48,4 +48,4 @@ def solution(n): doctest.testmod() - print(solution(int(input().strip()))) \ No newline at end of file + print(solution(int(input().strip()))) From 254be323f90b63abd8bb09beedc86892e154b602 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 14 Sep 2020 20:00:08 +0200 Subject: [PATCH 3/4] That number is larger than our acceptable range. --- project_euler/problem_04/sol1.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project_euler/problem_04/sol1.py b/project_euler/problem_04/sol1.py index 5708aceff060..227b594d0df7 100644 --- a/project_euler/problem_04/sol1.py +++ b/project_euler/problem_04/sol1.py @@ -21,7 +21,7 @@ def solution(n): >>> solution(10000) Traceback (most recent call last): ... - ValueError: It is larger number than our acceptable range. + ValueError: That number is larger than our acceptable range. """ # fetches the next number for number in range(n - 1, 9999, -1): @@ -37,10 +37,10 @@ def solution(n): # if 'number' is a product of two 3-digit numbers # then number is the answer otherwise fetch next number. while divisor != 99: - if (number % divisor == 0) and (len(str(number // divisor)) == 3): + if (number % divisor == 0) and (len(str(number // divisor)) == 3.0): return number divisor -= 1 - raise ValueError("It is larger number than our acceptable range.") + raise ValueError("That number is larger than our acceptable range.") if __name__ == "__main__": From 6a7e92276cb402862a1309eea90253231f468589 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Mon, 14 Sep 2020 18:00:35 +0000 Subject: [PATCH 4/4] updating DIRECTORY.md --- DIRECTORY.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index ac10afdc0ccd..1dceb887940c 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -85,10 +85,12 @@ * [Harriscorner](https://github.com/TheAlgorithms/Python/blob/master/computer_vision/harriscorner.py) ## Conversions + * [Binary To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_decimal.py) * [Decimal To Any](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_any.py) * [Decimal To Binary](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_binary.py) * [Decimal To Hexadecimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_hexadecimal.py) * [Decimal To Octal](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_octal.py) + * [Hexadecimal To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/hexadecimal_to_decimal.py) * [Prefix Conversions](https://github.com/TheAlgorithms/Python/blob/master/conversions/prefix_conversions.py) * [Roman To Integer](https://github.com/TheAlgorithms/Python/blob/master/conversions/roman_to_integer.py) * [Temperature Conversions](https://github.com/TheAlgorithms/Python/blob/master/conversions/temperature_conversions.py) @@ -222,6 +224,8 @@ ## File Transfer * [Receive File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/receive_file.py) * [Send File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/send_file.py) + * Tests + * [Test Send File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/tests/test_send_file.py) ## Fuzzy Logic * [Fuzzy Operations](https://github.com/TheAlgorithms/Python/blob/master/fuzzy_logic/fuzzy_operations.py) @@ -725,6 +729,7 @@ * [Binary Tree Traversals](https://github.com/TheAlgorithms/Python/blob/master/traversals/binary_tree_traversals.py) ## Web Programming + * [Covid Stats Via Xpath](https://github.com/TheAlgorithms/Python/blob/master/web_programming/covid_stats_via_xpath.py) * [Crawl Google Results](https://github.com/TheAlgorithms/Python/blob/master/web_programming/crawl_google_results.py) * [Current Stock Price](https://github.com/TheAlgorithms/Python/blob/master/web_programming/current_stock_price.py) * [Current Weather](https://github.com/TheAlgorithms/Python/blob/master/web_programming/current_weather.py) @@ -735,5 +740,6 @@ * [Fetch Jobs](https://github.com/TheAlgorithms/Python/blob/master/web_programming/fetch_jobs.py) * [Get Imdb Top 250 Movies Csv](https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_imdb_top_250_movies_csv.py) * [Get Imdbtop](https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_imdbtop.py) + * [Recaptcha Verification](https://github.com/TheAlgorithms/Python/blob/master/web_programming/recaptcha_verification.py) * [Slack Message](https://github.com/TheAlgorithms/Python/blob/master/web_programming/slack_message.py) * [World Covid19 Stats](https://github.com/TheAlgorithms/Python/blob/master/web_programming/world_covid19_stats.py)