Skip to content

Commit 9799ea5

Browse files
committed
Finalize changes after resolving conflicts
1 parent 5fb415f commit 9799ea5

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

dynamic_programming/travelling_salesman.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import sys
2-
3-
41
def tsp_dp(distances: list[list[float]]) -> tuple[float, list[int]]:
52
"""
63
Solves Traveling Salesman Problem using dynamic programming.
@@ -42,7 +39,7 @@ def solve(mask: int, pos: int) -> float:
4239
if state in dp:
4340
return dp[state]
4441

45-
minimum = float("inf")
42+
minimum = float('inf')
4643
min_next = -1
4744

4845
for next_city in range(n):
@@ -67,7 +64,7 @@ def solve(mask: int, pos: int) -> float:
6764
for _ in range(n - 1):
6865
next_pos = parent[(mask, pos)]
6966
path.append(next_pos)
70-
mask |= 1 << next_pos
67+
mask |= (1 << next_pos)
7168
pos = next_pos
7269

7370
return optimal_cost, path

0 commit comments

Comments
 (0)