Set the Python file maximum line length to 88 characters (#2122)

* flake8 --max-line-length=88

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
Christian Clauss
2020-06-16 10:09:19 +02:00
committed by GitHub
parent 9438c6bf0b
commit 9316e7c014
90 changed files with 473 additions and 320 deletions

View File

@@ -16,8 +16,8 @@ def valid_connection(
Checks whether it is possible to add next into path by validating 2 statements
1. There should be path between current and next vertex
2. Next vertex should not be in path
If both validations succeeds we return true saying that it is possible to connect this vertices
either we return false
If both validations succeeds we return True saying that it is possible to connect
this vertices either we return False
Case 1:Use exact graph as in main function, with initialized values
>>> graph = [[0, 1, 0, 1, 0],
@@ -52,7 +52,8 @@ def util_hamilton_cycle(graph: List[List[int]], path: List[int], curr_ind: int)
Pseudo-Code
Base Case:
1. Chceck if we visited all of vertices
1.1 If last visited vertex has path to starting vertex return True either return False
1.1 If last visited vertex has path to starting vertex return True either
return False
Recursive Step:
2. Iterate over each vertex
Check if next vertex is valid for transiting from current vertex
@@ -74,7 +75,8 @@ def util_hamilton_cycle(graph: List[List[int]], path: List[int], curr_ind: int)
>>> print(path)
[0, 1, 2, 4, 3, 0]
Case 2: Use exact graph as in previous case, but in the properties taken from middle of calculation
Case 2: Use exact graph as in previous case, but in the properties taken from
middle of calculation
>>> graph = [[0, 1, 0, 1, 0],
... [1, 0, 1, 1, 1],
... [0, 1, 0, 0, 1],

View File

@@ -12,8 +12,8 @@ solution = []
def isSafe(board, row, column):
"""
This function returns a boolean value True if it is safe to place a queen there considering
the current state of the board.
This function returns a boolean value True if it is safe to place a queen there
considering the current state of the board.
Parameters :
board(2D matrix) : board
@@ -56,8 +56,8 @@ def solve(board, row):
return
for i in range(len(board)):
"""
For every row it iterates through each column to check if it is feasible to place a
queen there.
For every row it iterates through each column to check if it is feasible to
place a queen there.
If all the combinations for that particular branch are successful the board is
reinitialized for the next possible combination.
"""

View File

@@ -1,9 +1,10 @@
"""
The sum-of-subsetsproblem states that a set of non-negative integers, and a value M,
determine all possible subsets of the given set whose summation sum equal to given M.
The sum-of-subsetsproblem states that a set of non-negative integers, and a
value M, determine all possible subsets of the given set whose summation sum
equal to given M.
Summation of the chosen numbers must be equal to given number M and one number can
be used only once.
Summation of the chosen numbers must be equal to given number M and one number
can be used only once.
"""
@@ -21,7 +22,8 @@ def create_state_space_tree(nums, max_sum, num_index, path, result, remaining_nu
Creates a state space tree to iterate through each branch using DFS.
It terminates the branching of a node when any of the two conditions
given below satisfy.
This algorithm follows depth-fist-search and backtracks when the node is not branchable.
This algorithm follows depth-fist-search and backtracks when the node is not
branchable.
"""
if sum(path) > max_sum or (remaining_nums_sum + sum(path)) < max_sum: