Skip to content

Commit 42d3106

Browse files
committed
Fix direct routes
There's a bug in the code for direct routes that are not over multiple hops. min-route expects a collection so we should always return a collection. This way it works for both direct and indirect routes: (find-path (grouped-routes routes) :paris :london) ;; => {:cost 236, :best [:paris :london]} (find-path (grouped-routes routes) :paris :budapest) ;; => {:cost 251, :best [:paris :milan :vienna :budapest]}
1 parent a1502fb commit 42d3106

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Chapter06/Exercise6.07/train_routes.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
(= position destination) path
5656

5757
(get-in route-lookup [position destination])
58-
(conj path destination)
58+
[(conj path destination)]
5959

6060
:otherwise-we-search
6161
(let [path-set (set path)

0 commit comments

Comments
 (0)