correct d8p2 and add debug print
This commit is contained in:
parent
65267a5850
commit
1a7326555a
@ -8,10 +8,11 @@ From r To :- From to _-To.
|
|||||||
answer(Answer) :-
|
answer(Answer) :-
|
||||||
starts(Starts),
|
starts(Starts),
|
||||||
routes(Starts, Routes),
|
routes(Starts, Routes),
|
||||||
collapse_routes(Routes, _-(Answer-_-_)).
|
collapse_routes(Routes, _-(_-Answer-_)).
|
||||||
|
|
||||||
collapse_routes([X], X).
|
collapse_routes([X], X).
|
||||||
collapse_routes(Routes, Collapsed) :-
|
collapse_routes(Routes, Collapsed) :-
|
||||||
|
writef('Collapsing: %t\n', [Routes]),
|
||||||
sort(2, @=<, Routes, [Route1, Route2 | CdrRoutes]),
|
sort(2, @=<, Routes, [Route1, Route2 | CdrRoutes]),
|
||||||
unify2(Route1, Route2, 0-0-0-0, [], NewRoute),
|
unify2(Route1, Route2, 0-0-0-0, [], NewRoute),
|
||||||
collapse_routes([NewRoute | CdrRoutes], Collapsed).
|
collapse_routes([NewRoute | CdrRoutes], Collapsed).
|
||||||
|
Loading…
Reference in New Issue
Block a user