From 08c8bb5ad51e3b25f0662a3834f188b749be077e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 6 May 2020 03:32:40 +0200 Subject: [PATCH] Deal with maps (#1945) * Deal with maps Try with the search term "pizza" to see why this was done in #1932 * fixup! Format Python code with psf/black push * Update armstrong_numbers.py * updating DIRECTORY.md * Update crawl_google_results.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> --- DIRECTORY.md | 4 ++++ maths/armstrong_numbers.py | 15 +++++++++------ project_euler/problem_26/sol1.py | 1 + web_programming/crawl_google_results.py | 5 ++++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 94d303afc0d5..61783b0e5bcf 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -15,6 +15,7 @@ * [All Permutations](https://github.com/TheAlgorithms/Python/blob/master/backtracking/all_permutations.py) * [All Subsequences](https://github.com/TheAlgorithms/Python/blob/master/backtracking/all_subsequences.py) * [Coloring](https://github.com/TheAlgorithms/Python/blob/master/backtracking/coloring.py) + * [Hamiltonian Cycle](https://github.com/TheAlgorithms/Python/blob/master/backtracking/hamiltonian_cycle.py) * [Minimax](https://github.com/TheAlgorithms/Python/blob/master/backtracking/minimax.py) * [N Queens](https://github.com/TheAlgorithms/Python/blob/master/backtracking/n_queens.py) * [Sudoku](https://github.com/TheAlgorithms/Python/blob/master/backtracking/sudoku.py) @@ -89,6 +90,7 @@ * [Number Of Possible Binary Trees](https://github.com/TheAlgorithms/Python/blob/master/data_structures/binary_tree/number_of_possible_binary_trees.py) * [Red Black Tree](https://github.com/TheAlgorithms/Python/blob/master/data_structures/binary_tree/red_black_tree.py) * [Segment Tree](https://github.com/TheAlgorithms/Python/blob/master/data_structures/binary_tree/segment_tree.py) + * [Segment Tree Other](https://github.com/TheAlgorithms/Python/blob/master/data_structures/binary_tree/segment_tree_other.py) * [Treap](https://github.com/TheAlgorithms/Python/blob/master/data_structures/binary_tree/treap.py) * Data Structures * Heap @@ -499,6 +501,8 @@ * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_25/sol1.py) * [Sol2](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_25/sol2.py) * [Sol3](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_25/sol3.py) + * Problem 26 + * [Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_26/sol1.py) * Problem 27 * [Problem 27 Sol1](https://github.com/TheAlgorithms/Python/blob/master/project_euler/problem_27/problem_27_sol1.py) * Problem 28 diff --git a/maths/armstrong_numbers.py b/maths/armstrong_numbers.py index 39a1464a9aa6..d30ed2e430a0 100644 --- a/maths/armstrong_numbers.py +++ b/maths/armstrong_numbers.py @@ -41,15 +41,18 @@ def armstrong_number(n: int) -> bool: temp //= 10 return n == sum -def narcissistic_number(n:int) -> bool: + +def narcissistic_number(n: int) -> bool: """Return True if n is a narcissistic number or False if it is not""" - - expo = len(str(n)) #power, all number will be raised to - temp = [(int(i)**expo) for i in str(n)] # each digit will be multiplied expo times - - # check if sum of cube of each digit is equal to number + + expo = len(str(n)) # power, all number will be raised to + # each digit will be multiplied expo times + temp = [(int(i) ** expo) for i in str(n)] + + # check if sum of cube of each digit is equal to number return n == sum(temp) + def main(): """ Request that user input an integer and tell them if it is Armstrong number. diff --git a/project_euler/problem_26/sol1.py b/project_euler/problem_26/sol1.py index 7b8c44c9c828..cab8e0eb580b 100644 --- a/project_euler/problem_26/sol1.py +++ b/project_euler/problem_26/sol1.py @@ -5,6 +5,7 @@ in its decimal fraction part. """ + def find_digit(numerator: int, digit: int) -> int: """ Considering any range can be provided, diff --git a/web_programming/crawl_google_results.py b/web_programming/crawl_google_results.py index 79b69e71c6b3..7d2be7c03c22 100644 --- a/web_programming/crawl_google_results.py +++ b/web_programming/crawl_google_results.py @@ -19,4 +19,7 @@ print(len(links)) for link in links: - webbrowser.open(f"http://google.com{link.get('href')}") + if link.text == "Maps": + webbrowser.open(link.get("href")) + else: + webbrowser.open(f"http://google.com{link.get('href')}")