Click here to Skip to main content
15,886,812 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Playing with memory

Sindhu and Alistair play a memory game involving of a sequence of random
numbers between 1 and 10, inclusive, that is called out one at a time.

Each player can remember up to 5 previous numbers. When the called
number is in a player's memory, that player is awarded a point. If it's not,
the player adds the called number to his memory, removing another number
if his memory is full.

Both players start with empty memories. Both players always add new
missed numbers to their memory but use a different strategy in deciding
which number to remove:

Sindhu's strategy is to remove the number that hasn't been called in the
longest time.

Alistair's strategy is to remove the number that's been in the memory the
longest time.

Example game:
Turn Callednumber Sindhu's memory Sindhu's score Alistair's memory Alistair's score
1	1	  1	           0	         1	            0
2	2	  1,2	           0	         1,2	            0
3 	4	  1,2,4	           0	         1,2,4	            0 
4	6	  1,2,4,6	   0	         1,2,4,6	    0
5 	1	  1,2,4,6	   1	         1,2,4,6	    1
6	8	  1,2,4,6,8	   1	         1,2,4,6,8	    1
7	10	  1,4,6,8,10	   1	         2,4,6,8,10	    1
8	2	  1,2,6,8,10	   1	         2,4,6,8,10	    2
9	4	  1,2,4,8,10	   1	         2,4,6,8,10	    2
10	1	  1,2,4,8,10	   2	         1,4,6,8,10	    3
<blockquote class="FQ"><div class="FQA">Quote:</div>

Denoting Sindhu's score by S and Alistair's score by A.

The game is for a total of 20 called numbers, with the property that all
numbers would be called equal number of times (2 times each across 20
call-outs).

Given a set of 20 called numbers in a sequence, identify the winner of this game the earliest in the sequence.
Posted
Updated 4-Jan-12 9:01am
v2
Comments
Richard MacCutchan 4-Jan-12 10:18am    
Do you have a programming question?
Vanathi.A 4-Jan-12 10:26am    
yes it is a programming question.
I don't need the exact coding.
I need the algorithm to implement this.
fjdiewornncalwe 4-Jan-12 10:31am    
So what is the question? You have forgotten that. Just dumping your assignment here is not how to get help. We will not just do your homework for you.

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think.
 
Share this answer
 
Comments
Vanathi.A 4-Jan-12 11:23am    
The problem is related to algorithms. I think this is a site for suggestions or solutions. So no one has the right to categorize any particular post.
Sergey Alexandrovich Kryukov 4-Jan-12 12:18pm    
OK, I just categorized this post as abuse. Will you dispute that?
--SA
fjdiewornncalwe 4-Jan-12 15:02pm    
I've just categorized your post as homework... :)
Sergey Alexandrovich Kryukov 4-Jan-12 12:20pm    
Tell them, Griff! A 5. After all, too many more boring assignments... if they don't wont to learn from their own hard work, who is going to be a looser?
--SA
Vanathi.A 5-Jan-12 11:41am    
Oh I am really sorry! I did not have enough time to spend on this dispute!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900