Skip to content

Commit ce0f65e

Browse files
authored
Update travelling_salesman_problem.py
1 parent 32f76b3 commit ce0f65e

File tree

1 file changed

+0
-13
lines changed

1 file changed

+0
-13
lines changed

dynamic_programming/travelling_salesman_problem.py

-13
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ def tsp(distances: list[list[int]]) -> int:
1313
tour visiting all cities.
1414
Raises:
1515
ValueError: If any distance is negative.
16-
17-
>>> tsp([[0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30],
18-
[20, 25, 30, 0]])
19-
80
20-
>>> tsp([[0, 29, 20, 21], [29, 0, 15, 17], [20, 15, 0, 28],
21-
[21, 17, 28, 0]])
22-
69
23-
>>> tsp([[0, 10, -15, 20], [10, 0, 35, 25], [15, 35, 0, 30],
24-
[20, 25, 30, 0]]) # doctest: +ELLIPSIS
25-
Traceback (most recent call last):
26-
...
27-
ValueError: Distance cannot be negative
2816
"""
2917
n = len(distances)
3018
if any(distances[i][j] < 0 for i in range(n) for j in range(n)):
@@ -54,5 +42,4 @@ def visit(city: int, mask: int) -> int:
5442

5543
if __name__ == "__main__":
5644
import doctest
57-
5845
doctest.testmod()

0 commit comments

Comments
 (0)