A standard deck of 52 cards contains,
inter alia, four Queens.
After a perfect shuffle, one turns cards from the top one after another, until the first Queen appears.
Please provide your justified estimate at what step will the 1st Queen appear.
For the perfect shuffle, the deck is divided into two equal packs. Then the two packs are interleaved. There's a choice as to which pack should supply the odd position cards and the other the even. Call one choice a and the other b; there are 16 possibilities for the sequence of a's and b's.
clearvars,clc
stats=double.empty(0);
for a=['ab']
for b=['ab']
for c=['ab']
for d=['ab']
seq=[a b c d];
deck='aaaa22223333444455556666777788889999xxxxjjjjqqqqkkkk';
for i=1:4
typ=seq(i);
p1=deck(1:26);
p2=deck(27:52);
if typ=='a'
deck(1:2:51)=p1;
deck(2:2:52)=p2;
else
deck(1:2:51)=p2;
deck(2:2:52)=p1;
end
end
f=strfind(deck,'q');
disp([seq ' ' num2str(f(1))])
stats(end+1)=f(1);
end
end
end
end
mean(stats)
finds the place depends on the sequence of types of perfect shuffle after making the cut into two packs:
aaaa 7
aaab 8
aaba 5
aabb 6
abaa 3
abab 4
abba 1
abbb 2
baaa 15
baab 16
baba 13
babb 14
bbaa 11
bbab 12
bbba 9
bbbb 10
ans =
8.5
>>
showing the average is at position 8.5
If, however, the choice of half-pack is consistent (either aaaa or bbbb) the answer will be position 7 or 10 respectively.
The same table as above, showing the positions of all four queens:
aaaa 7
7 23 39 42
aaab 8
8 24 40 41
aaba 5
5 21 37 44
aabb 6
6 22 38 43
abaa 3
3 19 35 38
abab 4
4 20 36 37
abba 1
1 17 33 40
abbb 2
2 18 34 39
baaa 15
15 31 34 50
baab 16
16 32 33 49
baba 13
13 29 36 52
babb 14
14 30 35 51
bbaa 11
11 27 30 46
bbab 12
12 28 29 45
bbba 9
9 25 32 48
bbbb 10
10 26 31 47
ans =
8.5
Edited on January 30, 2024, 9:28 am
|
Posted by Charlie
on 2024-01-30 09:23:01 |