Qm
BrainteasersJane StreetSIG

Eight perfect shuffles restore the deck

A perfect out-shuffle splits a 52-card deck into two halves of 26 and interleaves them exactly, with the original top card staying on top. (An in-shuffle interleaves so that the original top card becomes second.)

  1. How many perfect out-shuffles return a 52-card deck to its original order?
  2. How many in-shuffles are needed?
  3. Explain the calculation.
Show a hint

Track where card number k goes. For an out-shuffle, a card at position k (counting from 0) moves to position 2k modulo 51. So you need the smallest n with 2 to the n leaving remainder 1 when divided by 51.

Your answer

Solving needs a free account

Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.

Discussion

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. No full solutions here. Hints and approaches only.
  2. Complexity, edge cases and intuition are the point.
  3. Interview experiences are welcome. Respect your NDAs.

Loading discussion…

Learn the concepts

The theory behind this question.

Related questions

One helper who may swap two slips100 prisoners and 100 boxesThe last digit of seven to the seven to the sevenThe last two digits of seven to the power 2024Three prisoners, three boxes, two looks each
All questions →