Skip to content

Commit 7bd83fd

Browse files
committed
Standardize output to int
1 parent ed8b6e3 commit 7bd83fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

graphs/traveling_salesman_problem.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def tsp_brute_force(graph: list[list[int]]) -> int:
3333
total_cost = sum(graph[path[i]][path[i + 1]] for i in range(n))
3434
min_path = min(min_path, total_cost)
3535

36-
return min_path
36+
return int(min_path)
3737

3838

3939
def tsp_dp(graph: list[list[int]]) -> int:
@@ -78,7 +78,7 @@ def tsp_dp(graph: list[list[int]]) -> int:
7878

7979
# After completing visits to all cities,
8080
# return to city 0 and obtain the minimum value.
81-
return min(dp[(1 << n) - 1][i] + graph[i][0] for i in range(1, n))
81+
return int(min(dp[(1 << n) - 1][i] + graph[i][0] for i in range(1, n)))
8282

8383

8484
def tsp_greedy(graph: list[list[int]]) -> int:
@@ -132,7 +132,7 @@ def tsp_greedy(graph: list[list[int]]) -> int:
132132
total_cost += graph[current][0]
133133
path.append(0)
134134

135-
return total_cost
135+
return int(total_cost)
136136

137137

138138
def test_tsp_example() -> None:

0 commit comments

Comments
 (0)