From eb9c145dc9525cc6b6ba233866fba1858460e873 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 5 May 2020 14:34:25 +0200 Subject: [PATCH 1/5] Deal with maps Try with the search term "pizza" to see why this was done in #1932 --- web_programming/crawl_google_results.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web_programming/crawl_google_results.py b/web_programming/crawl_google_results.py index 79b69e71c6b3..f731748ca5b5 100644 --- a/web_programming/crawl_google_results.py +++ b/web_programming/crawl_google_results.py @@ -18,5 +18,7 @@ links = list(soup.select(".eZt8xd"))[:5] print(len(links)) - for link in links: + if link.text == "Maps": + webbrowser.open(link.get('href')) + else: webbrowser.open(f"http://google.com{link.get('href')}") From 8644500ab26510d18c8a1b08ec27a26923e37219 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Tue, 5 May 2020 12:35:34 +0000 Subject: [PATCH 2/5] fixup! Format Python code with psf/black push --- maths/armstrong_numbers.py | 16 ++++++++++------ project_euler/problem_26/sol1.py | 1 + web_programming/crawl_google_results.py | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/maths/armstrong_numbers.py b/maths/armstrong_numbers.py index 39a1464a9aa6..33d8ecee0768 100644 --- a/maths/armstrong_numbers.py +++ b/maths/armstrong_numbers.py @@ -41,15 +41,19 @@ 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 + 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 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 f731748ca5b5..d8ab9adcde20 100644 --- a/web_programming/crawl_google_results.py +++ b/web_programming/crawl_google_results.py @@ -19,6 +19,6 @@ print(len(links)) if link.text == "Maps": - webbrowser.open(link.get('href')) + webbrowser.open(link.get("href")) else: webbrowser.open(f"http://google.com{link.get('href')}") From 785ab21fc387af3204334fce45ec8b35a1460988 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 5 May 2020 14:40:11 +0200 Subject: [PATCH 3/5] Update armstrong_numbers.py --- maths/armstrong_numbers.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/maths/armstrong_numbers.py b/maths/armstrong_numbers.py index 33d8ecee0768..d30ed2e430a0 100644 --- a/maths/armstrong_numbers.py +++ b/maths/armstrong_numbers.py @@ -46,9 +46,8 @@ 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 + # 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) From 50a4ca2336d63a0234fd73451d4ef2c5210bccfd Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Tue, 5 May 2020 12:40:36 +0000 Subject: [PATCH 4/5] updating DIRECTORY.md --- DIRECTORY.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 631b3a88a12c..64dca674729b 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 From 67bd9ef77b78796af276cde908fecdb3f99b3550 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 5 May 2020 14:42:28 +0200 Subject: [PATCH 5/5] Update crawl_google_results.py --- web_programming/crawl_google_results.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/web_programming/crawl_google_results.py b/web_programming/crawl_google_results.py index d8ab9adcde20..7d2be7c03c22 100644 --- a/web_programming/crawl_google_results.py +++ b/web_programming/crawl_google_results.py @@ -18,7 +18,8 @@ links = list(soup.select(".eZt8xd"))[:5] print(len(links)) - if link.text == "Maps": - webbrowser.open(link.get("href")) - else: - webbrowser.open(f"http://google.com{link.get('href')}") + for link in links: + if link.text == "Maps": + webbrowser.open(link.get("href")) + else: + webbrowser.open(f"http://google.com{link.get('href')}")