Code Room
CodingHard
Question
Given a complete directed graph as an n x n distance matrix dist (dist[i][j] is the cost from city i to city j, dist[i][i]=0), find the minimum cost of a tour that starts at city 0, visits every city exactly once, and returns to city 0 (closed Traveling Salesman). Return that minimum cost. Constraints: 1 <= n <= 13, 0 <= dist[i][j] <= 10000.
Implement
tsp_min_tour(dist: list[list[int]]) → intExamples
in
[[[0,10,15,20],[10,0,35,25],[15,35,0,30],[20,25,30,0]]]out80What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.