diff --git a/DIRECTORY.md b/DIRECTORY.md index 94d303afc..61783b0e5 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 39a1464a9..d30ed2e43 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 7b8c44c9c..cab8e0eb5 100644 --- a/project_euler/problem_26/sol1.py +++ b/project_euler/problem_26/sol1.py @@ -5,6 +5,7 @@ Find the value of d < 1000 for which 1/d contains the longest recurring cycle 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 79b69e71c..7d2be7c03 100644 --- a/web_programming/crawl_google_results.py +++ b/web_programming/crawl_google_results.py @@ -19,4 +19,7 @@ if __name__ == "__main__": 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')}")