1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| mot_mystere(M) :-
%mots(L, _),
%length(L, NbL),
%NbL1 is NbL-1,
%lettres_possibles(NbL1, [], L1),
lettres_possibles(4, [], L),
mot_possible(L, M).
mot_possible(LC, M) :-
maplist(member, M, LC),
test(M).
test(M) :-
forall(mots(L, Nb), let_comm(M, L, Nb)).
let_comm([],[],0).
let_comm([X|L],[X|M],N1):-
!,
let_comm(L,M,N),
N1 is N + 1.
let_comm([_|L],[_|M],R):-
let_comm(L,M,R).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lettres_possibles( -1, L, L):- !.
lettres_possibles(N, L, L1):-
collect(N, H),
N1 is N - 1,
lettres_possibles(N1, [H | L], L1).
get_lettre(N, L) :-
mots(LL, Nb),
Nb > 0,
nth0(N, LL, L),
mots(LL1, 0),
forall(member(L1, LL1), L1\= L).
collect(N, H) :-
setof(L, get_lettre(N, L), H). |
Partager