Docstrings and formatting improvements (#2418) · zinating/algorithms-python@10aa214 · GitHub
Skip to content

Commit 10aa214

Browse files
Hasenncclauss
andauthored
Docstrings and formatting improvements (TheAlgorithms#2418)
* Fix spelling in docstrings * Improve comments and formatting * Update print statement to reflect doctest change * improve phrasing and apply black * Update rat_in_maze.py This method is recursive starting from (i, j) and going in one of four directions: up, down, left, right. If a path is found to destination it returns True otherwise it returns False. Co-authored-by: Christian Clauss <cclauss@me.com>
1 parent 799fde4 commit 10aa214

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

backtracking/hamiltonian_cycle.py

Lines changed: 3 additions & 3 deletions

backtracking/rat_in_maze.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
def solve_maze(maze: list) -> bool:
22
"""
3-
This method solves rat in maze algorithm.
4-
In this problem we have n by n matrix and we have start point and end point
5-
we want to go from source to distination. In this matrix 0 are block paths
6-
1 are open paths we can use.
3+
This method solves the "rat in maze" problem.
4+
In this problem we have some n by n matrix, a start point and an end point.
5+
We want to go from the start to the end. In this matrix zeroes represent walls
6+
and ones paths we can use.
77
Parameters :
88
maze(2D matrix) : maze
99
Returns:
10-
Return: True is maze has a solution or False if it does not.
10+
Return: True if the maze has a solution or False if it does not.
1111
>>> maze = [[0, 1, 0, 1, 1],
1212
... [0, 0, 0, 0, 0],
1313
... [1, 0, 1, 0, 1],
@@ -47,13 +47,13 @@ def solve_maze(maze: list) -> bool:
4747
... [0, 1, 0],
4848
... [1, 0, 0]]
4949
>>> solve_maze(maze)
50-
Solution does not exists!
50+
No solution exists!
5151
False
5252
5353
>>> maze = [[0, 1],
5454
... [1, 0]]
5555
>>> solve_maze(maze)
56-
Solution does not exists!
56+
No solution exists!
5757
False
5858
"""
5959
size = len(maze)
@@ -63,16 +63,15 @@ def solve_maze(maze: list) -> bool:
6363
if solved:
6464
print("\n".join(str(row) for row in solutions))
6565
else:
66-
print("Solution does not exists!")
66+
print("No solution exists!")
6767
return solved
6868

6969

7070
def run_maze(maze, i, j, solutions):
7171
"""
72-
This method is recursive method which starts from i and j
73-
and goes with 4 direction option up, down, left, right
74-
if path found to destination it breaks and return True
75-
otherwise False
72+
This method is recursive starting from (i, j) and going in one of four directions:
73+
up, down, left, right.
74+
If a path is found to destination it returns True otherwise it returns False.
7675
Parameters:
7776
maze(2D matrix) : maze
7877
i, j : coordinates of matrix

boolean_algebra/quine_mc_cluskey.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def main():
146146
minterms = [
147147
int(x)
148148
for x in input(
149-
"Enter the decimal representation of Minterms 'Spaces Seprated'\n"
149+
"Enter the decimal representation of Minterms 'Spaces Separated'\n"
150150
).split()
151151
]
152152
binary = decimal_to_binary(no_of_variable, minterms)

cellular_automata/one_dimensional.py

Lines changed: 3 additions & 2 deletions

0 commit comments

Comments
 (0)