mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-20 00:02:04 +00:00
black fixes and Travis CI fixes (#2160)
* black format * updating DIRECTORY.md * fixes * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
parent
c534e77cb1
commit
2d3d660155
|
@ -205,6 +205,7 @@
|
|||
* [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 Cost Path](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/minimum_cost_path.py)
|
||||
* [Minimum Partition](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/minimum_partition.py)
|
||||
* [Optimal Binary Search Tree](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/optimal_binary_search_tree.py)
|
||||
* [Rod Cutting](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/rod_cutting.py)
|
||||
|
@ -230,11 +231,11 @@
|
|||
* [Articulation Points](https://github.com/TheAlgorithms/Python/blob/master/graphs/articulation_points.py)
|
||||
* [Basic Graphs](https://github.com/TheAlgorithms/Python/blob/master/graphs/basic_graphs.py)
|
||||
* [Bellman Ford](https://github.com/TheAlgorithms/Python/blob/master/graphs/bellman_ford.py)
|
||||
* [Bfs](https://github.com/TheAlgorithms/Python/blob/master/graphs/bfs.py)
|
||||
* [Bfs Shortest Path](https://github.com/TheAlgorithms/Python/blob/master/graphs/bfs_shortest_path.py)
|
||||
* [Bidirectional A Star](https://github.com/TheAlgorithms/Python/blob/master/graphs/bidirectional_a_star.py)
|
||||
* [Bidirectional Breadth First Search](https://github.com/TheAlgorithms/Python/blob/master/graphs/bidirectional_breadth_first_search.py)
|
||||
* [Breadth First Search](https://github.com/TheAlgorithms/Python/blob/master/graphs/breadth_first_search.py)
|
||||
* [Breadth First Search 2](https://github.com/TheAlgorithms/Python/blob/master/graphs/breadth_first_search_2.py)
|
||||
* [Breadth First Search Shortest Path](https://github.com/TheAlgorithms/Python/blob/master/graphs/breadth_first_search_shortest_path.py)
|
||||
* [Check Bipartite Graph Bfs](https://github.com/TheAlgorithms/Python/blob/master/graphs/check_bipartite_graph_bfs.py)
|
||||
* [Check Bipartite Graph Dfs](https://github.com/TheAlgorithms/Python/blob/master/graphs/check_bipartite_graph_dfs.py)
|
||||
|
|
|
@ -102,4 +102,4 @@ if __name__ == "__main__":
|
|||
import doctest
|
||||
|
||||
doctest.testmod()
|
||||
main()
|
||||
# main()
|
||||
|
|
|
@ -4,7 +4,7 @@ from typing import List
|
|||
|
||||
|
||||
def minimum_cost_path(matrix: List[List[int]]) -> int:
|
||||
'''
|
||||
"""
|
||||
Find the minimum cost traced by all possible paths from top left to bottom right in
|
||||
a given matrix
|
||||
|
||||
|
@ -13,7 +13,7 @@ def minimum_cost_path(matrix: List[List[int]]) -> int:
|
|||
|
||||
>>> minimum_cost_path([[2, 1, 4], [2, 1, 3], [3, 2, 1]])
|
||||
7
|
||||
'''
|
||||
"""
|
||||
|
||||
# preprocessing the first row
|
||||
for i in range(1, len(matrix[0])):
|
||||
|
|
|
@ -5,24 +5,9 @@ Finding connected components in graph
|
|||
|
||||
"""
|
||||
|
||||
test_graph_1 = {
|
||||
0: [1, 2],
|
||||
1: [0, 3],
|
||||
2: [0],
|
||||
3: [1],
|
||||
4: [5, 6],
|
||||
5: [4, 6],
|
||||
6: [4, 5],
|
||||
}
|
||||
test_graph_1 = {0: [1, 2], 1: [0, 3], 2: [0], 3: [1], 4: [5, 6], 5: [4, 6], 6: [4, 5]}
|
||||
|
||||
test_graph_2 = {
|
||||
0: [1, 2, 3],
|
||||
1: [0, 3],
|
||||
2: [0],
|
||||
3: [0, 1],
|
||||
4: [],
|
||||
5: [],
|
||||
}
|
||||
test_graph_2 = {0: [1, 2, 3], 1: [0, 3], 2: [0], 3: [0, 1], 4: [], 5: []}
|
||||
|
||||
|
||||
def dfs(graph: dict, vert: int, visited: list) -> list:
|
||||
|
|
|
@ -5,22 +5,9 @@ Finding strongly connected components in directed graph
|
|||
|
||||
"""
|
||||
|
||||
test_graph_1 = {
|
||||
0: [2, 3],
|
||||
1: [0],
|
||||
2: [1],
|
||||
3: [4],
|
||||
4: [],
|
||||
}
|
||||
test_graph_1 = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}
|
||||
|
||||
test_graph_2 = {
|
||||
0: [1, 2, 3],
|
||||
1: [2],
|
||||
2: [0],
|
||||
3: [4],
|
||||
4: [5],
|
||||
5: [3],
|
||||
}
|
||||
test_graph_2 = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}
|
||||
|
||||
|
||||
def topology_sort(graph: dict, vert: int, visited: list) -> list:
|
||||
|
|
|
@ -35,9 +35,7 @@ class TestClass(unittest.TestCase):
|
|||
# profit = [10, -20, 30, 40, 50, 60]
|
||||
# weight = [2, 4, 6, 8, 10, 12]
|
||||
# max_weight = 15
|
||||
self.assertRaisesRegex(
|
||||
ValueError, "Weight can not be negative.",
|
||||
)
|
||||
self.assertRaisesRegex(ValueError, "Weight can not be negative.")
|
||||
|
||||
def test_negative_weight_value(self):
|
||||
"""
|
||||
|
|
|
@ -80,10 +80,7 @@ the third document in the corpus.")
|
|||
) # strip all punctuation and replace it with ''
|
||||
docs = corpus_without_punctuation.split("\n")
|
||||
term = term.lower()
|
||||
return (
|
||||
len([doc for doc in docs if term in doc]),
|
||||
len(docs),
|
||||
)
|
||||
return (len([doc for doc in docs if term in doc]), len(docs))
|
||||
|
||||
|
||||
def inverse_document_frequency(df: int, N: int) -> float:
|
||||
|
|
Loading…
Reference in New Issue
Block a user