Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- domains
- list=symbol*
- predicates
- more(symbol, symbol)
- less(symbol, symbol)
- iscity(symbol)
- iscmd(symbol)
- solve(symbol,symbol,symbol,symbol,symbol,symbol)
- solvel(list, list, integer)
- iscityl(list, integer)
- iscmdl(list, integer)
- lessl(list, list)
- notmorel(list, list)
- goal
- /**
- * GOALS. Uncomment your chose.
- */
- %solve(A,B,C,X,Y,Z).
- %solvel(L1, L2, 3).
- clauses
- /**
- * CHAPTER 0: Data
- */
- % List of known references
- more(krasnodar, chelyabinsk).
- more(samara, chelyabinsk).
- more(dinamo, krasnodar).
- more(spartak, torpedo).
- % List of known cities
- iscity(krasnodar).
- iscity(chelyabinsk).
- iscity(samara).
- % List of known teams' names
- iscmd(torpedo).
- iscmd(spartak).
- iscmd(dinamo).
- /**
- * CHAPTER 1: Predicates for fixed data.
- */
- less(A, B):-A<>B,not(more(A, B)).
- solve(A,B,C,X,Y,Z):-
- iscity(A),iscity(B),iscity(C),
- iscmd(X),iscmd(Y),iscmd(Z),
- not(more(X, A)),
- not(more(X, B)),
- not(more(X, C)),
- not(more(Y, B)),
- not(more(Y, C)),
- not(more(Z, C)),
- not(more(A, X)),
- not(more(A, Y)),
- not(more(A, Z)),
- not(more(B, Y)),
- not(more(B, Z)),
- not(more(C, Z)),
- less(A, B),
- less(A, C),
- less(B, C),
- less(X, Y),
- less(X, Z),
- less(Y, Z).
- /**
- * CHAPTER 2: Predicates for array data.
- */
- iscityl([], 0) :- !.
- iscityl([H|T], N) :- Ndec=N-1,iscity(H), iscityl(T, Ndec).
- iscmdl([], 0) :- !.
- iscmdl([H|T], N) :- Ndec=N-1,iscmd(H), iscmdl(T, Ndec).
- notmorel(_, []).
- notmorel([H1|T1], [H2|T2]) :- not(more(H1, H2)), notmorel(T1, T2), notmorel([H1|T1], T2).
- lessl(_, []).
- lessl([H|T], [H|T]) :- lessl([H|T], T).
- lessl([H1|T1], [H2|T2]) :- less(H1, H2),lessl(T1, T2),lessl([H1|T1], T2).
- solvel(LCity, LCmd, N):-
- iscityl(LCity, N), iscmdl(LCmd, N),
- notmorel(LCity, LCmd),
- notmorel(LCmd, LCity),
- lessl(LCmd, LCmd),
- lessl(LCity, LCity).
Add Comment
Please, Sign In to add comment