Skip to content

Feature/travelling salesman #12494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 2, 2025
commit aa46f1ad83a67dd1717295e224d17f15cbb9c00f
4 changes: 2 additions & 2 deletions dynamic_programming/travelling_salesman.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys

Check failure on line 1 in dynamic_programming/travelling_salesman.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

dynamic_programming/travelling_salesman.py:1:8: F401 `sys` imported but unused


def tsp_dp(distances: list[list[float]]) -> tuple[float, list[int]]:
Expand Down Expand Up @@ -35,7 +35,7 @@
if state in dp:
return dp[state]

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

for next_city in range(n):
Expand All @@ -60,7 +60,7 @@
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
Loading