All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Perfect Shuffle (Posted on 2004-05-19)
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.

 No Solution Yet Submitted by SilverKnight Rating: 4.2500 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re(6): Making a sequence (spoilers on the numbers) | Comment 9 of 20 |
(In reply to re(5): Making a sequence (spoilers on the numbers) by GOM)

"But is there a formula?"

This raises a philosophical question. The formula is quoted as "the multiplicative order of 2 (mod n)".  It happens that this function is not as well known as the sine function, or the ordinary log function, but it is a function.  (As mentioned in my post, it bears definitional similarity to logarithms, and to invent a notation could just as easily say mod7log-base-2(1).

The question is How can that be defined other than in a computer program?  However, though say the sine function is defined in terms of right triangles, etc., it still needs to be computed via some sort of program or algorithm, such as

DECLARE FUNCTION s# (x#)
DEFDBL A-Z
FOR arg = .1 TO 1 STEP .1
PRINT USING "#.############  "; s(arg); SIN(arg)
NEXT
END

FUNCTION s (x)
tot = x
term = x
n = 1
DO
n = n + 2
term = -term * x * x / ((n - 1) * n)
tot = tot + term
LOOP UNTIL ABS(term) < 1E-12
s = tot
END FUNCTION

where the function is evaluated and compared to the built-in sine function of the Basic interpreter/compiler.  The results do match:

`0.099833418129  0.0998334181290.198669333716  0.1986693337160.295520210932  0.2955202109320.389418347799  0.3894183477990.479425545143  0.4794255451430.564642480774  0.5646424807740.644217695216  0.6442176952160.717356099205  0.7173560992050.783326917964  0.783326917964`

The computer goes through a similar evaluation, though hidden from the user, in its evaluation of the sine function.

The case is probably even stronger for, say, logarithms, where there is not triangle-measuring way of coming up with evaluations of the function.

 Posted by Charlie on 2004-05-21 11:41:11

 Search: Search body:
Forums (0)