WIP: Travis CI: Lower flake8 max-complexity to 15 by cclauss · Pull Request #2139 · TheAlgorithms/Python · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
4 changes: 4 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* [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)
* [Knight Tour](https://github.com/TheAlgorithms/Python/blob/master/backtracking/knight_tour.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)
Expand Down Expand Up @@ -71,6 +72,8 @@
## Compression
* [Burrows Wheeler](https://github.com/TheAlgorithms/Python/blob/master/compression/burrows_wheeler.py)
* [Huffman](https://github.com/TheAlgorithms/Python/blob/master/compression/huffman.py)
* [Lempel Ziv](https://github.com/TheAlgorithms/Python/blob/master/compression/lempel_ziv.py)
* [Lempel Ziv Decompress](https://github.com/TheAlgorithms/Python/blob/master/compression/lempel_ziv_decompress.py)
* [Peak Signal To Noise Ratio](https://github.com/TheAlgorithms/Python/blob/master/compression/peak_signal_to_noise_ratio.py)

## Computer Vision
Expand Down Expand Up @@ -199,6 +202,7 @@
* [Longest Increasing Subsequence O(Nlogn)](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/longest_increasing_subsequence_o(nlogn).py)
* [Longest Sub Array](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/longest_sub_array.py)
* [Matrix Chain Order](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/matrix_chain_order.py)
* [Max Non Adjacent Sum](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/max_non_adjacent_sum.py)
* [Max Sub Array](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/max_sub_array.py)
* [Max Sum Contiguous Subsequence](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/max_sum_contiguous_subsequence.py)
* [Minimum Partition](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/minimum_partition.py)
Expand Down
18 changes: 9 additions & 9 deletions backtracking/knight_tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@


def get_valid_pos(position: Tuple[int], n: int) -> List[Tuple[int]]:
'''
"""
Find all the valid positions a knight can move to from the current position.

>>> get_valid_pos((1, 3), 4)
[(2, 1), (0, 1), (3, 2)]
'''
"""

y, x = position
positions = [
Expand All @@ -20,7 +20,7 @@ def get_valid_pos(position: Tuple[int], n: int) -> List[Tuple[int]]:
(y + 2, x + 1),
(y + 2, x - 1),
(y - 2, x + 1),
(y - 2, x - 1)
(y - 2, x - 1),
]
permissible_positions = []

Expand All @@ -33,23 +33,23 @@ def get_valid_pos(position: Tuple[int], n: int) -> List[Tuple[int]]:


def is_complete(board: List[List[int]]) -> bool:
'''
"""
Check if the board (matrix) has been completely filled with non-zero values.

>>> is_complete([[1]])
True

>>> is_complete([[1, 2], [3, 0]])
False
'''
"""

return not any(elem == 0 for row in board for elem in row)


def open_knight_tour_helper(board: List[List[int]], pos: Tuple[int], curr: int) -> bool:
'''
"""
Helper function to solve knight tour problem.
'''
"""

if is_complete(board):
return True
Expand All @@ -67,7 +67,7 @@ def open_knight_tour_helper(board: List[List[int]], pos: Tuple[int], curr: int)


def open_knight_tour(n: int) -> List[List[int]]:
'''
"""
Find the solution for the knight tour problem for a board of size n. Raises
ValueError if the tour cannot be performed for the given size.

Expand All @@ -78,7 +78,7 @@ def open_knight_tour(n: int) -> List[List[int]]:
Traceback (most recent call last):
...
ValueError: Open Kight Tour cannot be performed on a board of size 2
'''
"""

board = [[0 for i in range(n)] for j in range(n)]

Expand Down
7 changes: 4 additions & 3 deletions dynamic_programming/max_non_adjacent_sum.py