Most card games require shuffling the deck of playing cards at the start of the game. The goal of this procedure is to bring the cards in a randomized and unpredictable order to provide an element of chance in card games. Multiple techniques exist to shuffle a deck of cards.
Washing the cards — also known as Corgi, Chemmy, Irish, scramble or beginner shuffle — involves simply spreading the cards out face down, and sliding them around over each other with one's hands. Then the cards are moved into one pile so that they begin to intertwine and are then arranged back into a stack. This method is useful for beginners and small children or if one is inept at shuffling cards. However, washing the cards requires a large surface for spreading out the cards and takes longer than the other methods.
The overhand shuffle or stripping shuffle is another easy way of shuffling the cards, and is essentially a series of cuts. A group of cards at the bottom (or top) of the deck grasped between the thumb on one side and fingers on the other, lifted sideways out of the deck, and then placed on the top (or bottom). This process is repeated multiple times with random selections of cards in order to randomize them.
Another common shuffling technique is called the riffle shuffle or dovetail shuffle, in which near halves of the deck are held in each hand with the thumbs inward, then cards are released by the thumbs so that they fall to the table interleaved (see figure below). Many also lift the cards up after a riffle, forming what is called a bridge which puts the cards back into place. This can also be done by placing the halves flat on the table with their rear corners touching, then lifting the back edges with the thumbs while pushing the halves together. While this method is more difficult, it is often used in casinos because it minimizes the risk of exposing cards during the shuffle.
A riffle is called a perfect dovetail if
the deck to be shuffled has an even number of cards
this deck is broken exactly in center
cards are dropped from each half alternately
There are two types of perfect dovetail shuffles: if the top card moves to be second from the top then it is an in shuffle, otherwise it is known as an out shuffle (which preserves both the top and bottom cards). In 1923 T. Nelson Downs wrote in a letter to fellow magician Edward G. "Tex" McGuire:
Eight complete perfect dovetail out shuffles brings a deck of 52 playing cards to its original order.
This is demonstrated in the following schema:
start | cyc #1 | cyc #2 | cyc #3 | cyc #4 | cyc #5 | cyc #6 | cyc #7 | cyc #8 | |
---|---|---|---|---|---|---|---|---|---|
card #01 | A♠ | A♠ | A♠ | A♠ | A♠ | A♠ | A♠ | A♠ | A♠ |
card #02 | 2♠ | A♣ | A♥ | 7♣ | 4♥ | 9♠ | 5♠ | 3♠ | 2♠ |
card #03 | 3♠ | 2♠ | A♣ | A♥ | 7♣ | 4♥ | 9♠ | 5♠ | 3♠ |
card #04 | 4♠ | 2♣ | A♦ | 7♦ | X♦ | Q♥ | K♠ | 7♠ | 4♠ |
card #05 | 5♠ | 3♠ | 2♠ | A♣ | A♥ | 7♣ | 4♥ | 9♠ | 5♠ |
card #06 | 6♠ | 3♣ | 2♥ | 8♠ | 4♣ | 2♦ | 8♥ | J♠ | 6♠ |
card #07 | 7♠ | 4♠ | 2♣ | A♦ | 7♦ | X♦ | Q♥ | K♠ | 7♠ |
card #08 | 8♠ | 4♣ | 2♦ | 8♥ | J♠ | 6♠ | 3♣ | 2♥ | 8♠ |
card #09 | 9♠ | 5♠ | 3♠ | 2♠ | A♣ | A♥ | 7♣ | 4♥ | 9♠ |
card #10 | X♠ | 5♣ | 3♥ | 8♣ | 4♦ | 9♥ | J♣ | 6♥ | X♠ |
card #11 | J♠ | 6♠ | 3♣ | 2♥ | 8♠ | 4♣ | 2♦ | 8♥ | J♠ |
card #12 | Q♠ | 6♣ | 3♦ | 8♦ | J♥ | Q♣ | 6♦ | X♥ | Q♠ |
card #13 | K♠ | 7♠ | 4♠ | 2♣ | A♦ | 7♦ | X♦ | Q♥ | K♠ |
card #14 | A♥ | 7♣ | 4♥ | 9♠ | 5♠ | 3♠ | 2♠ | A♣ | A♥ |
card #15 | 2♥ | 8♠ | 4♣ | 2♦ | 8♥ | J♠ | 6♠ | 3♣ | 2♥ |
card #16 | 3♥ | 8♣ | 4♦ | 9♥ | J♣ | 6♥ | X♠ | 5♣ | 3♥ |
card #17 | 4♥ | 9♠ | 5♠ | 3♠ | 2♠ | A♣ | A♥ | 7♣ | 4♥ |
card #18 | 5♥ | 9♣ | 5♥ | 9♣ | 5♥ | 9♣ | 5♥ | 9♣ | 5♥ |
card #19 | 6♥ | X♠ | 5♣ | 3♥ | 8♣ | 4♦ | 9♥ | J♣ | 6♥ |
card #20 | 7♥ | X♣ | 5♦ | 9♦ | J♦ | Q♦ | K♥ | K♣ | 7♥ |
card #21 | 8♥ | J♠ | 6♠ | 3♣ | 2♥ | 8♠ | 4♣ | 2♦ | 8♥ |
card #22 | 9♥ | J♣ | 6♥ | X♠ | 5♣ | 3♥ | 8♣ | 4♦ | 9♥ |
card #23 | X♥ | Q♠ | 6♣ | 3♦ | 8♦ | J♥ | Q♣ | 6♦ | X♥ |
card #24 | J♥ | Q♣ | 6♦ | X♥ | Q♠ | 6♣ | 3♦ | 8♦ | J♥ |
card #25 | Q♥ | K♠ | 7♠ | 4♠ | 2♣ | A♦ | 7♦ | X♦ | Q♥ |
card #26 | K♥ | K♣ | 7♥ | X♣ | 5♦ | 9♦ | J♦ | Q♦ | K♥ |
card #27 | A♣ | A♥ | 7♣ | 4♥ | 9♠ | 5♠ | 3♠ | 2♠ | A♣ |
card #28 | 2♣ | A♦ | 7♦ | X♦ | Q♥ | K♠ | 7♠ | 4♠ | 2♣ |
card #29 | 3♣ | 2♥ | 8♠ | 4♣ | 2♦ | 8♥ | J♠ | 6♠ | 3♣ |
card #30 | 4♣ | 2♦ | 8♥ | J♠ | 6♠ | 3♣ | 2♥ | 8♠ | 4♣ |
card #31 | 5♣ | 3♥ | 8♣ | 4♦ | 9♥ | J♣ | 6♥ | X♠ | 5♣ |
card #32 | 6♣ | 3♦ | 8♦ | J♥ | Q♣ | 6♦ | X♥ | Q♠ | 6♣ |
card #33 | 7♣ | 4♥ | 9♠ | 5♠ | 3♠ | 2♠ | A♣ | A♥ | 7♣ |
card #34 | 8♣ | 4♦ | 9♥ | J♣ | 6♥ | X♠ | 5♣ | 3♥ | 8♣ |
card #35 | 9♣ | 5♥ | 9♣ | 5♥ | 9♣ | 5♥ | 9♣ | 5♥ | 9♣ |
card #36 | X♣ | 5♦ | 9♦ | J♦ | Q♦ | K♥ | K♣ | 7♥ | X♣ |
card #37 | J♣ | 6♥ | X♠ | 5♣ | 3♥ | 8♣ | 4♦ | 9♥ | J♣ |
card #38 | Q♣ | 6♦ | X♥ | Q♠ | 6♣ | 3♦ | 8♦ | J♥ | Q♣ |
card #39 | K♣ | 7♥ | X♣ | 5♦ | 9♦ | J♦ | Q♦ | K♥ | K♣ |
card #40 | A♦ | 7♦ | X♦ | Q♥ | K♠ | 7♠ | 4♠ | 2♣ | A♦ |
card #41 | 2♦ | 8♥ | J♠ | 6♠ | 3♣ | 2♥ | 8♠ | 4♣ | 2♦ |
card #42 | 3♦ | 8♦ | J♥ | Q♣ | 6♦ | X♥ | Q♠ | 6♣ | 3♦ |
card #43 | 4♦ | 9♥ | J♣ | 6♥ | X♠ | 5♣ | 3♥ | 8♣ | 4♦ |
card #44 | 5♦ | 9♦ | J♦ | Q♦ | K♥ | K♣ | 7♥ | X♣ | 5♦ |
card #45 | 6♦ | X♥ | Q♠ | 6♣ | 3♦ | 8♦ | J♥ | Q♣ | 6♦ |
card #46 | 7♦ | X♦ | Q♥ | K♠ | 7♠ | 4♠ | 2♣ | A♦ | 7♦ |
card #47 | 8♦ | J♥ | Q♣ | 6♦ | X♥ | Q♠ | 6♣ | 3♦ | 8♦ |
card #48 | 9♦ | J♦ | Q♦ | K♥ | K♣ | 7♥ | X♣ | 5♦ | 9♦ |
card #49 | X♦ | Q♥ | K♠ | 7♠ | 4♠ | 2♣ | A♦ | 7♦ | X♦ |
card #50 | J♦ | Q♦ | K♥ | K♣ | 7♥ | X♣ | 5♦ | 9♦ | J♦ |
card #51 | Q♦ | K♥ | K♣ | 7♥ | X♣ | 5♦ | 9♦ | J♦ | Q♦ |
card #52 | K♦ | K♦ | K♦ | K♦ | K♦ | K♦ | K♦ | K♦ | K♦ |
Write a function dovetail that takes a sequence (list or tuple) with an even number of elements. The function must return a new list (list) containing the elements from the given sequence after they have been shuffled out with a perfect dovetail (first and last card remain on their original position after shuffling). If a sequence with an odd number of elements is passed, the function must raise an AssertionError with the message even number of cards expected.
Write a function riffle that takes a sequence (list or tuple) with an even number of elements. The function also has an optional parameter repeats that takes a number $$n \in \mathbb{N}$$ (int; default value: $$n=1$$). The function must return a new list (list) containing the elements from the given sequence after they have been shuffled out with $$n$$ perfect dovetails. If a sequence with an odd number of elements is passed, the function must raise an AssertionError with the message even number of cards expected.
Write a function cycle that takes an even number $$n \in \mathbb{N}_0$$ (int). The function must return a number $$c \in \mathbb{N}_0$$ (int) that indicates the minimal number of perfect dovetail shuffles out that are required to bring a deck of $$n$$ different playing cards back to its original order. The function must raise an AssertionError with the message even number of cards expected, in case an odd number was passed to the function.
>>> dovetail(['2D', 'KC', 'JC', '3S', 'QD', 'KH'])
['2D', '3S', 'KC', 'QD', 'JC', 'KH']
>>> dovetail(('2D', '7C', 'AC', 'KH', '9C', '6S', '3S', '4H'))
['2D', '9C', '7C', '6S', 'AC', '3S', 'KH', '4H']
>>> dovetail(['JS', 'XH', 'AC', '5H', '6C', '9D', 'AS'])
Traceback (most recent call last):
AssertionError: even number of cards expected
>>> riffle(['2D', 'KC', 'JC', '3S', 'QD', 'KH'])
['2D', '3S', 'KC', 'QD', 'JC', 'KH']
>>> riffle(('2D', '7C', 'AC', 'KH', '9C', '6S', '3S', '4H'), repeats=2)
['2D', 'AC', '9C', '3S', '7C', 'KH', '6S', '4H']
>>> riffle(['JS', 'XH', 'AC', '5H', '6C', '9D', 'AS'], 42)
Traceback (most recent call last):
AssertionError: even number of cards expected
>>> cycle(2)
1
>>> cycle(8)
3
>>> cycle(52)
8
>>> cycle(137)
Traceback (most recent call last):
AssertionError: even number of cards expected
Here's what it looks like in the hands of a skilled shuffler.