Choosing Four Numbers from 1..9 Using Seven Coin Flips
Nov/15/2009
There are 126 ways to choose four items from a set of 9, and there are 128
results from flipping a two-sided coin seven times. The procedure below lets
you make a random choice of four numbers from nine using seven flips of a
coin. The procedure will succeed about 98% of the time. The rest of the time
it will fail, requiring you to start over.
Before we start, we divide the numbers into four pairs, {1,5}, {2,6}, {3,7},
and {4,8}, with 9 leftover as a special case. The procedure makes use of the
diagram below, which can be drawn on a scrap of paper. Coins are placed on the
diagram to indicate which numbers are chosen.
If 9 is not one of the chosen numbers, the four numbers either fall
into four different pairs (well call this 1111), just two
different pairs (22) or two will fall into one pair and two into
two others (211). If 9 is one of the chosen numbers, the
other three numbers either fall into three different pairs (9-111),
or two will fall into one pair and one into another (9-21).
The procedure will use three or four flips to decide between these cases, and
also to decide which pairs are non-empty. The final three or four flips then
finish off the selection.
The procedure:
- Flip three coins and place them, in the order they are flipped, on the
numbers 1, 2 and 3.
- [1111 case] If there are no heads, we will use one number from
each of the four pairs.
- Pick up the three coins.
- Consider the four pairs from left to right. For each of four flips,
if it is heads, place a coin to the higher number in the pair.
Otherwise, place one on the lower number.
- The procedure is finished. The four coins mark the chosen numbers.
- [211 case] If there is only one head, we will use three of the
pairs, with the head being used (indirectly) to indicate which pair to
double up.
- Make a note of whether the head is on 1, 2 or 3. Call this value
X.
- Place a coin on 4 (1..4 all have coins)
- Flip two coins to determine which of the four pairs will be empty.
Interpreting them in binary, remove the coin from the indicated pair.
- Considering the three chosen pairs left to right, place a coin on the
higher number of the Xth pair.
- Consider the two remaining pairs from left to right. For each of two
flips, if it is heads, move the marker coin to the higher number in the
pair. Otherwise, leave it on the lower number.
- The procedure is finished. The four coins mark the chosen numbers.
- Flip a coin and place it on 4.
- [9-21 case] If there are only two heads, 9 is chosen, and we
will use two of the pairs.
- There is one tail among 1, 2 or 3. Make a note of which it is. Call
this value X.
- Pick up the four coins.
- Flip two coins to determine which of the four pairs will be have both
numbers chosen. Interpreting them in binary, place coins on both the
lower and higher numbers of the the indicated pair.
- Considering the three empty pairs left to right, flip a coin and place
it on the Xth pair; if it is heads, place it on the higher
number, otherwise on the lower.
- Place a coin on 9.
- The procedure is finished. The four coins mark the chosen numbers.
- [9-111 case] If there are three heads, 9 is chosen, and we
will use three of the pairs.
- The three heads mark the chosen pairs. Remove the tail.
- Consider the chosen pairs from left to right. For each of three flips,
if it is heads, move the marker coin to the higher number in the pair.
Otherwise, leave it on the lower number.
- Place a coin on 9.
- The procedure is finished. The four coins mark the chosen numbers.
- [22 case] Otherwise, there are four heads.
- Pick up the four coins.
- Flip three coins and place them, in the order they are flipped, on the
numbers 1, 2 and 3.
- If all four are the same, pick them up and start over at (A).
- Pick up all the tails.
- If only one coin is placed, place a coin on number four. After this
step, two coins will have been placed.
- Place coins on the higher number for each of the two chosen pairs.
- The procedure is finished. The four coins mark the chosen numbers.
Back to Bobs main Dice and Coins page.