:-lib(fd). zebre(L):- L=[Anglais, Espagnol, Ukrainien, Japonais, Norvegien,Rouge, Vert,…
- User
:-lib(fd).
zebre(L):- L=[Anglais, Espagnol, Ukrainien, Japonais, Norvegien,Rouge, Vert, Blanc, Jaune, Bleu,Cafe, The, Lait, Vin, Eau, OldGold, Kools, Chesterfields, Gitanes, Cravens, Chien, Escargots, Renard, Cheval, Zebre], L::1..5, alldifferent([Anglais, Espagnol, Ukrainien, Japonais, Norvegien]), alldifferent([Rouge, Vert, Blanc, Jaune, Bleu]), alldifferent([Cafe, The, Lait, Vin, Eau]), alldifferent([OldGold, Kools, Chesterfields, Gitanes, Cravens]), alldifferent([Chien, Escargots, Renard, Cheval, Zebre]),
Anglais#=Rouge,Chien#=Espagnol,Cafe#=Vert,Ukrainien#=The,Blanc#=Vert+1,Norvegien#=1 #/ Bleu#=Norvegien+1,Bleu#=Norvegien-1,Lait#=3,Kools#=Jaune,Japonais#=Cravens, Escargots#=OldGold,Gitanes#=Vin,Kools#=Cheval+1 #/ Kools#=Cheval-1,Chesterfields#=Renard+1 #/ Chesterfields#=Renard-1,
labeling(L).
zebre_aff(L):-zebre(L),(foreach(X,L)do writeln(X)).quoi chngazer
- Assistant
The Prolog code you provided is a partial implementation of the famous "Zebra Puzzle" also known as "Einstein's Riddle." The puzzle involves figuring out a series of relationships based on a set of constraints. The typical story behind the puzzle involves five houses, each of a different color, inhabited by people of different nationalities, who own different pets, drink different drinks, and smoke different brands of cigarettes.