Hi
I am new at Prolog, I learnt some of its concepts but still have difficulties in writing procedures
I have this issue, I need to write a porgram in prolog to solve it but I couldn't
It might be simple, but I found it hard for me as a beginner
question is this
We have a box contains red & yellow balls.
A man comes daily and gets 2 balls from the box, if he couldn't get 2 balls game finshes.
There is a heap of red balls next to the box.
If the 2 balls which the man withdrown from the box were similar , he puts red ball into the box,
while if they were different, he puts yellow ball in the box.
We suppose that the box is represented like this
initialCan([y, r, y, r, y, r, y, r, y, r]).
y represents yellow ball, r represents red ball
the man withdraw the 2 balls from the beginning of the list ,
then he puts back 1 ball also to the beginning of the list.
So what is the procedure in Prolog which gives the color of the last ball in the box whatever
was the box containing at the beginning?