In a perfect shuffle or perfect faro shuffle, the deck is split into equal halves of 26 cards which are then pushed together in a certain way so as to make them perfectly interweave.
The faro shuffle is performed by cutting the deck into two, preferably equal, packs in both hands as follows (right-handed): The cards are held from above in the right and from below in the left hand. Separation of the deck is done simply lifting up half the cards with the right hand thumb slightly and pushing the left hand's packet forward away from the right hand. The two packets are often crossed and slammed into each other as to align them. They are then pushed together by the short sides and bent (either up or down). The cards will then alternately fall into each other, much like a zipper. A flourish can be added by springing the packets together by applying pressure and bending them from above. The faro shuffle is a controlled shuffle which does not fully randomize a deck.
A faro shuffle which leaves the original top card at the top and the original bottom card at the bottom is known as an out shuffle; one which moves the original top card to second and the original bottom card to second bottom is known as an in shuffle.
A perfect faro shuffle, where the cards are perfectly alternated, is considered one of the most difficult sleights of card manipulation, because it requires the shuffler to cut the deck into two equal stacks and apply just the right pressure when pushing the half decks into each other. If one manages to perform eight perfect faro out-shuffles in a row, then the deck of 52 cards will be restored to its original order. If one can do perfect in-shuffles, then 26 shuffles will reverse the order of the deck and 26 more will restore it to its original order.
Shuffle vs. Sorting
A faro shuffle is not to be confused with a sorting algorithm. A perfect faro shuffle cycles the order of the cards into a fixed number of states. For a 52-card deck using perfect faro shuffles there are 8 possible states in the cycle. That is, a faro shuffle can only be used to return the deck to its order prior to faro shuffling; It will not sort a randomized deck, nor can it return a randomized deck back to new deck order. (Unless the randomized initial state of the deck just happens to be one of the permutations of faro shuffling a new deck.)
Below is a Python 3 implementation of a perfect faro shuffle:
class Deck(object): def __init__(self): self.cards = [ 'A♠', '2♠', '3♠', '4♠', '5♠', '6♠', '7♠', '8♠', '9♠', '10♠', 'J♠', 'Q♠', 'K♠', 'A♦', '2♦', '3♦', '4♦', '5♦', '6♦', '7♦', '8♦', '9♦', '10♦', 'J♦', 'Q♦', 'K♦', 'A♣', '2♣', '3♣', '4♣', '5♣', '6♣', '7♣', '8♣', '9♣', '10♣', 'J♣', 'Q♣', 'K♣', 'A♥', '2♥', '3♥', '4♥', '5♥', '6♥', '7♥', '8♥', '9♥', '10♥', 'J♥', 'Q♥', 'K♥'] def __eq__(self, other): return self.cards == other.cards def faro_shuffle(self): '''Shuffles the deck using a perfect faro shuffle.''' r =  for (a, b) in zip(self.cards[0:26], self.cards[26:]): r.append(a) r.append(b) self.cards = r original_deck = Deck() # A deck in new-deck-order we will use for comparison. shuffled_deck = Deck() # A deck we will repeatedly faro shuffle. for i in range(1, 1000): shuffled_deck.faro_shuffle() if shuffled_deck == original_deck: print("Deck is back in new-deck order after %s shuffles." % i) break
The program shuffles a 52-card deck until it returns to its original order. This happens in exactly 8 iterations (shuffles):
(promt)> python shuffle.py
Deck is back in new-deck order after 8 shuffles.
Group theory aspects
More generally, in , the perfect shuffle is the permutation that splits the set into 2 piles and interleaves them:
Formally, it sends
Analogously, the -perfect shuffle permutation is the element of that splits the set into k piles and interleaves them.
The -perfect shuffle, denote it , is the composition of the -perfect shuffle with an -cycle, so the sign of is:
The sign is thus 4-periodic:
The first few perfect shuffles are: and are trivial, and is the transposition .
- Diaconis, P.; R.L. Graham, and W.M. Kantor (1983). "The mathematics of perfect shuffles". Advances in Applied Mathematics 4 (2): 175–196. doi:10.1016/0196-8858(83)90009-X.