Skip to content
Snippets Groups Projects
Commit c77c5f3c authored by DARWICH ALI's avatar DARWICH ALI
Browse files

tp3 logique

parent f9f1679d
Branches
No related merge requests found
......@@ -13,4 +13,18 @@ len([],0).
len([_|T],N):- len(T,X), N is X+1.
estdans([E|_],E).
estdans([_|T],X):- estdans(T , X).
\ No newline at end of file
estdans([_|T],X):- estdans(T , X).
concatenation([],L):- write(L).
concatenation([H|L],E):- concatenation(L,[H|E]).
monconcat([],X,X).
monconcat([X|Q1], Y, [X|Q2]) :- monconcat(Q1, Y, Q2).
someleb([],N,N).
someleb([X|L], N, N0) :- N1 is X+N, someleb(L, N1,N0).
somele(L,N) :- someleb(L,0,N).
compte-aa([],0).
compte-aa([aa|L], N) :- compte-aa(L,N1), N is N1+1, !.
compte-aa([_|L], N) :- compte-aa(L,N).
\ No newline at end of file
estdans([E|_],E).
estdans([_|T],X):- estdans(T , X).
precede(T,T1,[T|L]):- estdans(L,T1).
precede(T,T1,[_|L]):- precede(T,T1,L).
debut(X,[X|_]).
tableau([m(C,N,S),m(C1,N1,S1),m(C2,N2,S2)]):- estdans(["anglais","espagnol" ,"français" ],N) , estdans(["anglais","espagnol" ,"français" ],N1),estdans(["anglais","espagnol" ,"français" ],N2), N1 \== N , N1 \== N2 , N \==N2 ,
estdans(["football","natation","tennis"],S) , estdans(["football","natation","tennis"],S1),estdans(["football","natation","tennis"],S2), S1 \== S , S1 \== S2 , S \==S2 ,
estdans(["blanc","bleu","vert"],C) , estdans(["blanc","bleu","vert"],C1),estdans(["blanc","bleu","vert"],C2), C1 \== C , C1 \== C2 , C \==C2 .
puzzle([m(C,N,S),m(C1,N1,S1),m(C2,N2,S2)]):-
tableau([m(C,N,S),m(C1,N1,S1),m(C2,N2,S2)]),
m("vert",_,"natation"),
precede(m(vert,_,_),m(_,espagnol,_),[m(C,N,S),m(C1,N1,S1),m(C2,N2,S2)]),
m(blanc,anglais,_),
precede(m(blanc,_,_),m(_,_,football),[m(C,N,S),m(C1,N1,S1),m(C2,N2,S2)]),
debut(m(_,_,tennis),[m(C,N,S),m(C1,N1,S1),m(C2,N2,S2)]).
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment