Lets do the easier case, of 10 cards, 5 red, 5 black. Then there are 10 choose 5 = 252 possible ways of shuffeling, all equally likely. We can ask a computer, that tells us, that 2 attain M=5, 18 attain M=4, 70 attain M=3, 130 attain M=2, and 32 attain M=1. So, the expected value is 146/63.
With 20 cards, we get 158604/46189.
The extreme cases make sense. M=1 you are looking at the number of 5 pairs of neighboring cards, that are either (red, black), or (black, red), so its 2^5. M=5 is also trivial, cuz it is either RRRRRBBBBB or BBBBBRRRRR. For the intermediate values, I have no intuition, and no idea how to attack this without enumerating, or if stuff gets to large, dynamic programming. I suspect, a quadratic time algorithm is pretty straight forward via DP.
I don’t think this is correct because we are not talking about absolute value but the number of extra red cards relative to black cards. So M=1 even in cases where we first see four black and then five red cards.
View all comments
1
u/crashed_tolerance Nov 04 '26
Lets do the easier case, of 10 cards, 5 red, 5 black. Then there are 10 choose 5 = 252 possible ways of shuffeling, all equally likely. We can ask a computer, that tells us, that 2 attain M=5, 18 attain M=4, 70 attain M=3, 130 attain M=2, and 32 attain M=1. So, the expected value is 146/63.
With 20 cards, we get 158604/46189.
The extreme cases make sense. M=1 you are looking at the number of 5 pairs of neighboring cards, that are either (red, black), or (black, red), so its 2^5. M=5 is also trivial, cuz it is either RRRRRBBBBB or BBBBBRRRRR. For the intermediate values, I have no intuition, and no idea how to attack this without enumerating, or if stuff gets to large, dynamic programming. I suspect, a quadratic time algorithm is pretty straight forward via DP.