Skip to content

Commit

Permalink
Switched to using destructuring syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
iancaffey committed Dec 8, 2016
1 parent d17e127 commit 477daab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kotlin/greedy/TravelingSalesman.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ fun solve(nodes: List<Triple<Int, Int, Int>>) {
path.add(start)
unvisited.remove(start) //prune start to manually create path from last node to start
while (unvisited.isNotEmpty()) {
val nearest = nearest(path.last(), unvisited)
distance += nearest.first
path.add(nearest.second)
unvisited.remove(nearest.second)
val (nearestDistance, nearest) = nearest(path.last(), unvisited)
distance += nearestDistance
path.add(nearest)
unvisited.remove(nearest)
}
println("Distance: " + (distance + distance(start, path.last())))
path.forEach { println(it.first) }
Expand Down

0 comments on commit 477daab

Please sign in to comment.