You have a deck of 52 cards - for convenience, number them 1 through 52. You cut the cards into two equal halves and shuffle them perfectly. That is, the cards were in the order
1,2,3,...,52
and now they are
1,27,2,28,...,26,52. Let's call this a perfect in-shuffle.
If you repeat this in-shuffling process, how many in-shuffles will it take for the deck to return to its initial ordering (taking for granted that the cards will eventually do so)?
________________________
How does the solution change if you have a deck of 64 cards, or 10, or in general, n cards? For odd integer values of n, in-shuffling will take 1,2,3,...,n to 1,(n+3)/2,2,(n+5)/2,...,n,(n+1)/2. For example, when n=5, the first in-shuffle yields 1,4,2,5,3.
(In reply to
there's a pattern there. I just know it! by GOM)
For powers of 6 I get
6 4
36 12
216 28
1296 36
7776 620
46656 420
279936 111972
1679616 648
10077696 34524
60466176 9300
362797056 3154756
Using
DEFLNG A-Z
CLS
sz1 = 6
DO
size = sz1 - 1
lg = 1: pw = 2
DO
lg = lg + 1: pw = (pw * 2) MOD size
LOOP UNTIL pw MOD size = 1
shCt = lg
n = (size - 3) / 2
col = n \ 40
row = n MOD 40 + 1
PRINT sz1, shCt
sz1 = sz1 * 6
LOOP
|
Posted by Charlie
on 2004-05-25 11:46:31 |