Hello guys I'm still newbie, I still don't know how to solve this puzzle with Prolog, I did some try and seems wrong and incomplete and this is the question:
At a musical recital five students (John, Kate, Larry, Mary and Nick) performed five musical pieces. Two by Bach, two by Mozart and one by Vivaldi. There were three violinists and two pianists. Each student performed only one piece, and played only one instrument. Find the order of the students, their respective instruments and the composer, with the following conditions:
The composers were not played consecutively. Vivaldi was played last and Mozart was played first.
There was one piano piece that was played between two violin pieces, and two violin pieces between the first and last piano piece.
There were no piano pieces by Mozart.
Kate played third.
John played a piece by Mozart, and was immediately followed by Nick, who played the piano.
Mary did not play a piece by Vivaldi.
and here my half-code
:
List=[
musicians(_,_,_,_),
musicians(_,_,_,_),
musicians(_,_,_,_),
musicians(_,_,_,_),
musicians(_,_,_,_)],
member(musicians(1,_,_,mozart),List) ,
member(musicians(5,_,_,vivaldi),List) ,
member(musicians(_,_,P1,mozart),List) ,P1\==piano,
member(musicians(3,kate,_,_),List) ,
member(musicians(_,john,_,mozart),List) ,
member(musicians(N1,nick,piano,_),List) ,N1==john_num+1,
member(musicians(_,mary,_,C1),List) ,C1\==vivaldi,
- I don't know how to write the #2 statement about piano and violin.
- I don't know how to write nick statement after John
N1==john_num+1,
- nah I'm just stuck to solve this problem using Prolog, even tho I already know the answer but totally new in prolog and still confused after read the tutorial.