I Took the time to translate it properly
Four people are in front of you: a male magician, a female magician, a wizard
and a witch. Each person has a bag of one or more coins.
The coins are made of bronze, copper, brass or tin.
Which bag contains the fewest coins?
Given that:
1 - There are no two bags of identical content.
2 – In a bag, there cannot be two of the same coins.
3 - A bag can contain either one, two or four coins.
4 - The sorcerer and the male magician each have a coin that
none of the other three have.
5 - All bags without a brass coin contain a bronze coin.
6 - All bags without tin coins do not contain a bronze coin either.
Create a Prolog program using depth-first search to find a solution
to this problem
I don't know where to go from here
coin(bronze).
coin(copper).
coin(brass).
coin(tin).
% 5: All bags without a brass coin contain a bronze coin.
hint_1(B) :- \+ \+ ( memberchk(brass, B) ; memberchk(bronze, B) ).
% 6: All bags without tin coins do not contain a bronze coin either.
hint_2(B) :- \+ ( \+ memberchk(tin, B), memberchk(bronze, B) ).
unique_coin(Us, Bags) :-
member(U, Us),
\+ (member(Bag, Bags), memberchk(U, Bag)).
bag(Cs) :-
% 3: A bag can contain either one, two or four coins
member(L, [1,2,4]), length(Cs, L),
% 2: In a bag, there cannot be two of the same coins.
foldl(ascending_coin, Cs, _, _).
ascending_coin(C, Prev, C) :-
coin(C),
Prev @< C..
%All bags are different
all_dif([]).
all_dif([L|Ls]) :-
maplist(dif(L), Ls),
all_dif(Ls).
bags(Bs) :-
Bs = [MM,FM,Wizard,Witch],
maplist(bag, Bs),
% 1: There are no two bags of identical content
all_dif(Bs),
% 4: The Wizard and the male magician each have a unique coin.
unique_coin(Wizard, [MM,FM,Witch]),
unique_coin(MM, [FM,Wizard,Witch]),
maplist(hint_1, Bs),
maplist(hint_2, Bs).