In: Statistics and Probability
Two people are playing an exciting game in which they take turns removing marbles from a bag. At the beginning of the game, this bag contains some red marbles and some blue marbles. The bag is transparent so at any time during the game, the players know exactly how many red and how many blue marbles are in the bag.
The players alternate taking turns. On a player’s turn, he or she must remove some marbles from the bag. The player chooses which marbles to remove, under the condition that he or she remove at least one marble and the marbles removed in a single turn are all the same color. The player to remove the last marble from the bag during his or her turn wins.
Assume that player 1 is playing the game with player 2, and player 1 makes the first move. If you were player 1, what optimal strategy could you use to play this game? Under what starting conditions would this optimal strategy guarantee a win, and why? What can you say about the outcome of the game if these starting conditions are not met?
(Hint: Try thinking of an invariant you could maintain during certain points of the game)
let's say player one start the game and pick out some of the marbles from the bag now it's chance for player to to play suppose player to takes out any number of marble from the bag of a particular colour now the strategy to win the game is to balance the number of marbles in the bag colour wise that means at any point of time there must be equal number of marbles red and blue present in the back so when the chance came back for player 12 play he must take out the number of marbles in such a way that the colours in the bag remains balanced. So at the end let's see there is X number of red marble and X number of Y marble now since we are balancing the number of marbles at every step so we must ensure that we must pick the last marble of a particular colour and leave one marble for the player to of other colour to pick up hence in this way we can ensure to win every time.
It's a standard programming problem you can also find it's solution on YouTube.