Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
ismember(A,[A|List1]). ismember(A,[X|List1]):- ismember(A,List1). lost(A,[],List). lost(A,[B|Tail],List):- nth0(IndexA,List,A), nth0(IndexB,List,B), IndexA < IndexB, lost(A,Tail,List). beat(A,[],List). beat(A,[B|Tail],List):- nth0(IndexA,List,A), nth0(IndexB,List,B), IndexA > IndexB, beat(A,Tail,List). isAllDiferent([A,B,C,D,E,F,G,H,I,J]). writen(A,0). writen(A,N):- N >0, write(A), TmpN is N-1, writen(A,TmpN). myPrint([],N). myPrint(_,0). myPrint([A|Tail],N):- N >=1, TmpN is N-1, myPrint(Tail,TmpN), writen(' ',N), write(A), write('\n'). find(List):- isAllDiferent(List), length(List,ListLen), ListLen is 10, lost('Simple Simon',['Zebra Wings'],List), beat('Zebra Wings',['Simple Simon','Frog Flippers','Apple Pie'],List), lost('Fizzy Pop',['Minty Mouth','Simple Simon','CD Player'],List), beat('Frog Flippers',['Windy Hill','CD Player','Simple Simon'],List), lost('Top Hat',['CD Player','Kippers','Apple Pie'],List), beat('CD Player',['Top Hat','Fizzy Pop'],List), lost('Apple Pie',['Zebra Wings','Simple Simon'],List), lost('Kippers',['Apple Pie','Frog Flippers'],List), beat('Frog Flippers',['Fizzy Pop','Minty Mouth','CD Player'],List), lost('CD Player',['Frog Flippers','Kippers','Apple Pie'],List), beat('Top Hat',['Fizzy Pop','Windy Hill'],List), lost('Minty Mouth',['Windy Hill','Simple Simon'],List), lost('Windy Hill',['Apple Pie','CD Player'],List). findAndPrint:- find(List), length(List,ListLen), myPrint(List,ListLen).