Skip to content

Instantly share code, notes, and snippets.

@moustaki
Created March 2, 2012 17:14
Show Gist options
  • Save moustaki/1959739 to your computer and use it in GitHub Desktop.
Save moustaki/1959739 to your computer and use it in GitHub Desktop.
train(london, sheffield).
train(sheffield, london).
train(sheffield, manchester).
train(manchester, london).
train(manchester, durham).
route(A, B, Route) :-
route(A, B, Route, [A]).
route(A, B, [B], _) :-
train(A, B).
route(A, B, [Z|Route], BeenThrough) :-
train(A, Z),
\+ member(Z, BeenThrough),
route(Z, B, Route, [Z|BeenThrough]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment