Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- reachable(Station1, Limit, Result) :-
- reachable(Station1, [Station1], 0, Limit, Result).
- reachable(Station1, Visited, TimeSpent, Limit, Result) :-
- (
- overground(Station1, Station2, Time);
- overground(Station2, Station1, Time)
- ),
- \+member(Station2,Visited),
- NewTimeSpent is TimeSpent + Time,
- (
- NewTimeSpent =< Limit,
- Result = Station2
- ;
- reachable(Station2, [Station2|Visited], NewTimeSpent, Limit, Result)
- ).
Add Comment
Please, Sign In to add comment