Skip to content

Commit 1769cb9

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent e9adddd commit 1769cb9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

dynamic_programming/travelling_salesman_problem.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22

3+
34
def tsp(distances: list[list[int]]) -> int:
45
"""
56
Solves the Travelling Salesman Problem (TSP)
@@ -44,8 +45,11 @@ def visit(city: int, mask: int) -> int:
4445
min_cost = min(min_cost, new_cost)
4546
memo[city][mask] = min_cost # Store result in the memoization table
4647
return min_cost
48+
4749
return visit(0, 1) # Start from city 0 with city 0 visited
4850

51+
4952
if __name__ == "__main__":
5053
import doctest
54+
5155
doctest.testmod()

0 commit comments

Comments
 (0)