diff --git a/DIRECTORY.md b/DIRECTORY.md index 5f9046cc7..b34658b32 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -18,6 +18,7 @@ * [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) + * [Rat In Maze](https://github.com/TheAlgorithms/Python/blob/master/backtracking/rat_in_maze.py) * [Sudoku](https://github.com/TheAlgorithms/Python/blob/master/backtracking/sudoku.py) * [Sum Of Subsets](https://github.com/TheAlgorithms/Python/blob/master/backtracking/sum_of_subsets.py) diff --git a/digital_image_processing/resize/resize.py b/digital_image_processing/resize/resize.py index afcacda4b..f33e80e58 100644 --- a/digital_image_processing/resize/resize.py +++ b/digital_image_processing/resize/resize.py @@ -50,7 +50,7 @@ class NearestNeighbour: :param y: Destination X coordinate :return: Parent X coordinate based on `y ratio` >>> nn = NearestNeighbour(imread("digital_image_processing/image_data/lena.jpg", - 1), 100, 100) + ... 1), 100, 100) >>> nn.ratio_y = 0.5 >>> nn.get_y(4) 2 diff --git a/divide_and_conquer/convex_hull.py b/divide_and_conquer/convex_hull.py index de67cb1e0..cf2c7f835 100644 --- a/divide_and_conquer/convex_hull.py +++ b/divide_and_conquer/convex_hull.py @@ -325,10 +325,10 @@ def convex_hull_recursive(points): >>> convex_hull_recursive([[0, 0], [1, 0], [10, 0]]) [(0.0, 0.0), (10.0, 0.0)] >>> convex_hull_recursive([[-1, 1],[-1, -1], [0, 0], [0.5, 0.5], [1, -1], [1, 1], - [-0.75, 1]]) + ... [-0.75, 1]]) [(-1.0, -1.0), (-1.0, 1.0), (1.0, -1.0), (1.0, 1.0)] >>> convex_hull_recursive([(0, 3), (2, 2), (1, 1), (2, 1), (3, 0), (0, 0), (3, 3), - (2, -1), (2, -4), (1, -3)]) + ... (2, -1), (2, -4), (1, -3)]) [(0.0, 0.0), (0.0, 3.0), (1.0, -3.0), (2.0, -4.0), (3.0, 0.0), (3.0, 3.0)] """ diff --git a/maths/gamma.py b/maths/gamma.py index febbee9a5..9193929ba 100644 --- a/maths/gamma.py +++ b/maths/gamma.py @@ -29,7 +29,8 @@ def gamma(num: float) -> float: 40320.0 >>> from math import gamma as math_gamma - >>> all(gamma(i)/math_gamma(i) <= 1.000000001 and abs(gamma(i)/math_gamma(i)) > .99999999 for i in range(1, 50)) + >>> all(.99999999 < gamma(i) / math_gamma(i) <= 1.000000001 + ... for i in range(1, 50)) True diff --git a/searches/tabu_search.py b/searches/tabu_search.py index cc4c95ead..f0c3241db 100644 --- a/searches/tabu_search.py +++ b/searches/tabu_search.py @@ -139,10 +139,19 @@ def find_neighborhood(solution, dict_of_neighbours): from the solution that the method took as an input Example: - >>> find_neighborhood(['a','c','b','d','e','a']) # doctest: +NORMALIZE_WHITESPACE - [['a','e','b','d','c','a',90], [['a','c','d','b','e','a',90], - ['a','d','b','c','e','a',93], ['a','c','b','e','d','a',102], - ['a','c','e','d','b','a',113], ['a','b','c','d','e','a',93]] + >>> find_neighborhood(['a', 'c', 'b', 'd', 'e', 'a'], + ... {'a': [['b', '20'], ['c', '18'], ['d', '22'], ['e', '26']], + ... 'c': [['a', '18'], ['b', '10'], ['d', '23'], ['e', '24']], + ... 'b': [['a', '20'], ['c', '10'], ['d', '11'], ['e', '12']], + ... 'e': [['a', '26'], ['b', '12'], ['c', '24'], ['d', '40']], + ... 'd': [['a', '22'], ['b', '11'], ['c', '23'], ['e', '40']]} + ... ) # doctest: +NORMALIZE_WHITESPACE + [['a', 'e', 'b', 'd', 'c', 'a', 90], + ['a', 'c', 'd', 'b', 'e', 'a', 90], + ['a', 'd', 'b', 'c', 'e', 'a', 93], + ['a', 'c', 'b', 'e', 'd', 'a', 102], + ['a', 'c', 'e', 'd', 'b', 'a', 113], + ['a', 'b', 'c', 'd', 'e', 'a', 119]] """ neighborhood_of_solution = [] @@ -209,7 +218,7 @@ def tabu_search( best_cost_index = len(best_solution) - 1 found = False - while found is False: + while not found: i = 0 while i < len(best_solution):