Two robots play Concentration as follows:
Pairs of matching cards are laid face down in random positions on the table.
On each turn, a robot may flip over two cards (one at a time) to try to get a match. If it is a match, the robot collects those cards and goes again. If it is not a match, the cards are laid face down again and it is the other robot's turn.
Both robots have perfect memory, so a match will be made whenever possible with cards that have already been revealed.
To move the game along, both robots have been programmed to turn over a new unrevealed card when no matches can be made.
The robot with the most collected cards wins the game.
If the robots play with the least number of cards needed so that the probability of either robot winning is less than half, and if the probability that the robot who went first wins the game is q p where p and q are co-prime positive integers, then find p + q .
(Note: a computer is probably required to find the solution.)
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.
This got too complicated for me so I had to use a computer program (earlier) to test the possibilities. I'm very impressed by your solution!
The following Python Code shows that the least number of cards needed for the probability of either robot winning to be less than half is 8 cards, so that Player 1 wins at a 4 0 5 4 0 5 1 8 5 5 2 7 ≈ 0 . 4 5 7 6 probability, Player 2 wins at a 2 0 2 7 0 2 5 8 7 0 7 7 8 ≈ 0 . 4 2 9 6 probability, and a tie happens at a 6 7 5 6 7 5 7 6 2 0 4 ≈ 0 . 1 1 2 8 probability.
Therefore p = 1 8 5 5 2 7 , q = 4 0 5 4 0 5 , and p + q = 5 9 0 9 3 2 .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
Very nice, and a fiendish problem! One question, though: there seems to be something strange happening with the probability of the second robot winning. I went about this a different way again (not elegant or compact enough to provide as a solution). I agree with @Mark Hennings that this probability should be 2 0 2 7 0 2 5 8 7 0 7 7 8 . If you look at the denominator of the fraction you found - 4 4 5 7 1 7 - you'll see it doesn't actually divide 2 0 2 7 0 2 5 (the total number of distinct games). However, the numerical values of the probabilities first differ in something like the 1 2 t h decimal place so there's something more going on here than a typo. Could this be a Python rounding issue?
Also, do you happen to know if this code should work in the coding environment on Brilliant? I don't seem to be able to get it working but perhaps I'm doing something wrong.
Log in to reply
Good catch! I edited my solution. Python did display the fraction incorrectly despite having the correct value, so it must be a Python rounding issue (maybe just with the Fraction function). Good thing I asked for the Player 1's probabilty and not Player 2's!
I'm not familiar with testing code on Brilliant. However, you can download Python for free from https://www.python.org/downloads/ and then test it by running it on your PC.
Log in to reply
Thanks! Seems the issue I had was a change in syntax for the PRINT statement/function between Python versions.
I'm still pottering around with this - the oscillation of the probabilities of the various outcomes against the number of pairs of cards in the game seems quite curious (for example, with five or six pairs of cards, the second robot is the most likely winner; with seven or eight pairs, it's the first robot). Do you have any intuition about what should happen as the number of pairs of cards increases? The benefit (or otherwise) of going first would seem to decrease, but I suspect that leads to each robot having a similar probability of winning rather than draws becoming the most likely outcome.
Log in to reply
@Chris Lewis – It is strange that the probability of which robot wins (seemingly) randomly goes back and forth. I'm not sure why nor do I know what would happen as the pairs of cards increase.
Problem Loading...
Note Loading...
Set Loading...
Suppose that A a , b , m , n is the probability that player A wins, given that he goes first, that the score is a : b (A has found a pairs, while B has found b ), that there are still m pairs to be identified, and that n singleton cards ( n ≤ m ) have already been uncovered. Suppose also that B a , b , n , m is the probability that player A wins, given that B goes first, the score is a : b , that m pairs remain and n singletons have been uncovered. There are 2 m − n cards from which A can choose; call the n cards that match a previously uncovered singleton "old", and the other 2 m − 2 n cards "new". At A 's turn, he might:
Thus we obtain the recurrence relation A a , b , m , n = ( 2 m − n ) ( 2 m − n − 1 ) 4 ( m − n ) ( m − n − 1 ) B a , b , m , n + 2 + ( 2 m − n ) ( 2 m − n − 1 ) 2 ( m − n ) n B a , b + 1 , m − 1 , n + ( 2 m − n ) ( 2 m − n − 1 ) 2 ( m − n ) A a + 1 , b , m − 1 , n + 2 m − n n A a + 1 , b , m − 1 , n − 1 Similar arguments apply to when it is B's turn to play, and we obtain the recurrence relation B a , b , m , n = ( 2 m − n ) ( 2 m − n − 1 ) 4 ( m − n ) ( m − n − 1 ) A a , b , m , n + 2 + ( 2 m − n ) ( 2 m − n − 1 ) 2 ( m − n ) n A a + 1 , b , m − 1 , n + ( 2 m − n ) ( 2 m − n − 1 ) 2 ( m − n ) B a , b + 1 , m − 1 , n + 2 m − n n B a , b + 1 , m − 1 , n − 1 and we have the initial conditions A a , b , 0 , 0 = B a , b , 0 , 0 = { 1 0 a > b o . w . We also have the probabilities D a , b , n , m A and D a , b , n , m B of a draw where (respectively) A and B play first and a , b , n , m have the same meaning as above. These probabilities have the recurrence relations D a , b , m , n A D a , b , m , n B = ( 2 m − n ) ( 2 m − n − 1 ) 4 ( m − n ) ( m − n − 1 ) D a , b , m , n + 2 B + ( 2 m − n ) ( 2 m − n − 1 ) 2 ( m − n ) n D a , b + 1 , m − 1 , n B + ( 2 m − n ) ( 2 m − n − 1 ) 2 ( m − n ) D a + 1 , b , m − 1 , n A + 2 m − n n D a + 1 , b , m − 1 , n − 1 A = ( 2 m − n ) ( 2 m − n − 1 ) 4 ( m − n ) ( m − n − 1 ) D a , b , m , n + 2 A + ( 2 m − n ) ( 2 m − n − 1 ) 2 ( m − n ) n D a + 1 , b , m − 1 , n A + ( 2 m − n ) ( 2 m − n − 1 ) 2 ( m − n ) D a , b + 1 , m − 1 , n B + 2 m − n n D a , b + 1 , m − 1 , n − 1 B together with the initial conditions D a , b , 0 , 0 A = D a , b , 0 , 0 B = { 1 0 a = b o . w . The probability that A wins a game with n pairs of cards, given that A goes first, is thus p A ( n ) = A 0 , 0 , n , 0 while the probability that B wins a game with n pairs of cards, given that A goes first, is p B ( n ) = 1 − A 0 , 0 , n , 0 − D 0 , 0 , n , 0 A Careful inspection shows that these recurrence relations are sufficient to evaluate all these probabilities. Computer checking gives that the smallest value of n for which both of p A ( n ) and p B ( n ) are less than 2 1 is n = 8 , with p A ( 8 ) = 4 0 5 4 0 5 1 8 5 5 2 7 p B ( 8 ) = 2 0 2 7 0 2 5 8 7 0 7 7 8 making the answer 1 8 5 5 2 7 + 4 0 5 4 0 5 = 5 9 0 9 3 2 .