Skip to content

Commit

Permalink
Finalize changes after resolving conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
aydinomer00 committed Jan 2, 2025
1 parent 5fb415f commit 9799ea5
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions dynamic_programming/travelling_salesman.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import sys


def tsp_dp(distances: list[list[float]]) -> tuple[float, list[int]]:
"""
Solves Traveling Salesman Problem using dynamic programming.
Expand Down Expand Up @@ -42,7 +39,7 @@ def solve(mask: int, pos: int) -> float:
if state in dp:
return dp[state]

minimum = float("inf")
minimum = float('inf')
min_next = -1

for next_city in range(n):
Expand All @@ -67,7 +64,7 @@ def solve(mask: int, pos: int) -> float:
for _ in range(n - 1):
next_pos = parent[(mask, pos)]
path.append(next_pos)
mask |= 1 << next_pos
mask |= (1 << next_pos)
pos = next_pos

return optimal_cost, path
Expand Down

0 comments on commit 9799ea5

Please sign in to comment.