CSE505/Assignment1/A/reach.P

27 lines
730 B
Plaintext
Raw Normal View History

2024-02-19 23:38:00 -05:00
%input :- [reachin1000]. % one way of reading input facts
2024-02-21 23:53:58 -05:00
:- include(reachin1000). % 2nd way of reading input facts
2024-02-19 23:38:00 -05:00
2024-02-22 23:50:15 -05:00
% Way 1
%reach(X) :- source(X).
%reach(Y) :- reach(X), edge(X,Y).
% Way 2
%reach(Y) :- reach(X), edge(X,Y).
%reach(X) :- source(X).
% Way 3
%reach(X) :- source(X).
%reach(Y) :- edge(X,Y), reach(X).
% Way 4
reach(Y) :- edge(X,Y), reach(X).
2024-02-19 23:38:00 -05:00
reach(X) :- source(X).
:- table reach/1.
printReach :- reach(X), write(X), write(' '), fail.
printReach.
%timeReach :- cputime(X), input, printReach, cputime(Y), T is Y-X, write(T).
%timeReach :- input, cputime(X), printReach, cputime(Y), T is Y-X, write(T).
timeReach :- cputime(X), printReach, cputime(Y), T is Y-X, write(T).
2024-02-21 23:53:58 -05:00
source(3).