Skip to content

Commit 1a0dd31

Browse files
authored
Change return type of dp function to float
1 parent d7134b0 commit 1a0dd31

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dynamic_programming/travelling_sales_person.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def travelling_salesman(cost_matrix: list[list[int]]) -> float:
3030
represents the cost of traveling from city i to city j.
3131
3232
Returns:
33-
int: The minimum total cost of the tour.
33+
float: The minimum total cost of the tour.
3434
"""
3535
n = len(cost_matrix)
3636
all_visited = (1 << n) - 1 # bitmask with all cities visited
3737

3838
@functools.cache
39-
def dp(mask: int, pos: int) -> int:
39+
def dp(mask: int, pos: int) -> float:
4040
# Base case: all cities visited, return cost to go back to start
4141
if mask == all_visited:
4242
return cost_matrix[pos][0]

0 commit comments

Comments
 (0)