% Scholten's coffee can problem % In Scholten's house there are white and black coffee beans: bean(white). bean(black). % There is a can of mixed beans can([]). can([Bean|Can]):- can(Can), bean(Bean). % In the morning, when bored he repeatedly does the following % He takes out two beans X and Y from the can. % If this is not possible he stops. % If they are the same he puts a black beean back in the can. % If they are different he puts a white bean back in the can. move([X,X|M], [black|M]). move([X,Y|M], [white|M]):-X\=Y. % What can be predicted about this game. moves(X,X). moves(X,Y):-move(X,Z), moves(Z,Y). game(Final_can):-can(Initial_can), moves(Initial_can,Final_can), write(initial_can(Initial_can)), nl. :-print('game, moves, move, can and bean loaded!'),nl,nl.