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

Home > General
Perfect Shuffle (Posted on 2004-05-19) Difficulty: 5 of 5
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
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

FOR arg = .1 TO 1 STEP .1
  PRINT USING "#.############  "; s(arg); SIN(arg)

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

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.099833418129
0.198669333716  0.198669333716
0.295520210932  0.295520210932
0.389418347799  0.389418347799
0.479425545143  0.479425545143
0.564642480774  0.564642480774
0.644217695216  0.644217695216
0.717356099205  0.717356099205
0.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
Please log in:
Remember me:
Sign up! | Forgot password

Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (1)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Copyright © 2002 - 2018 by Animus Pactum Consulting. All rights reserved. Privacy Information