A game of tokens is played with the following rules. In each round, the player with the most tokens gives one token to each of the other players and also places one token in the discard pile. The game ends when some player runs out of tokens. Players A, B, and C start with 100, 99, and 98 tokens, respectively. How many rounds will there be in the game?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
thanks
In the first round, player A loses three tokens while B and C both gain one each... well, B and C 's number of tokens don't really matter because it's player A who ends up having the lowest count of tokens: A ends up having 9 7 tokens left first, then by B and then by C in the succeeding rounds. At the fourth round, A ends up having 9 6 left first and so on. Thus, it's only A 's token stock that needs attention in this game as player A 's would be the first to reach 0 tokens after n rounds.
To find n , we should notice that from the first round when A has 9 7 tokens left, after every three rounds, A loses a net of 1 token. Thus the number of rounds needed to end the game would be
n n n = 1 + 9 7 × 3 = 1 + 2 9 1 = 2 9 2
>>> stack = [100,99,98];
>>> while (stack[0] or stack[1] or stack[2]):
... if stack[0] > 0 and stack[1] > 0 and stack[2] > 0:
... k = stack.index(max(stack))
... stack[(k+1)%3] += 1
... stack[(k+2)%3] += 1
... stack[k] -= 3
... else: break
... print stack
even i did it by coding ... but actually its cheating :)
Lets start with the terminating condition for this problem
This happens when the players have [3,2,1] then the first player will be bust out of tokens
so that's 1 turn.
before that if we have for example [5,4,3] this means that we would have 3 turns with 5 tokens on one of the players [5,4,3]->[2,5,4]->[3,2,5]->[4,3,2] this goes on for all numbers [N,N-1,N-2] it only doesn't work when N=3 because it is the terminating condition
so this means that the number of turns is ((N-3) * 3) +1
= ((100-3)*3) +1 = 292
Problem Loading...
Note Loading...
Set Loading...
Look at a set of 3 rounds, where the players have x+1, x, and x-1 tokens. Each of the players will gain two tokens from the others and give away 3 tokens, so overall, each player will lose 1 token.
Therefore, after 97 sets of 3 rounds, or 291 rounds, the players will have 3, 2, and 1 tokens, respectively. After 1 more round, player A will give away his last 3 tokens and the game will stop. Hence round 292.