Structured Shuffles and the Josephus Problem

The Australian Shuffle consists of placing a deck of cards onto a table according to this rule: put the top card on the table, the next card on the bottom of the deck, and repeat until all the cards have been placed on the table. A natural question is “Where was the very last card placed located in the original deck?” Card trick magicians have known empirically for years that the fortieth card from the top of a standard fifty-two card deck is the final card placed by this shuffle. The moniker “Australian” comes from putting every other card “Down Under”. We develop a formula for the general case of N cards, and then extend that generalization further to cases involving the discard of k cards before or after putting one on the bottom of the deck. Finally, we discuss the connection of the Australian Shuffle and its generalizations to the famous Josephus problem.


Introduction
A colleague of ours who is an avid amateur magician introduced us to the traditional version of the Australian Shuffle, so named because a standard deck of cards is dealt one at a time onto a table according to the rule that after the top card is placed on the table, the next card is to be moved down under to the bottom of the deck, and then the process repeated until only one card remains... the final discard.Our friend knew that the card located at the fortieth position from the top in the original fifty-two card deck would always be that last card, but wanted an explanation.Here we consider a formula for a deck of any size.The Tasmanian Shuffle is the generalization where instead of placing one card on the table, we discard a fixed number of cards.
The Tasmanian Shuffle is related to the classical problem [1] of Flavius Josephus.Josephus was part of a Jewish military force that was battling the Romans in the first century AD.Josephus and forty of his comrades were trapped in a cave by the Romans, and rather than surrender, they decided to commit suicide as a group.The method chosen was for the soldiers to stand in a circle and, proceeding around the circle in a constant direction from a fixed starting point, every third soldier standing would be executed by the next temporarily surviving fellow around the circle.The standing part is critical, since any dead soldiers were ignored by this fatal algorithm on subsequent passes around the dwindling circle.Josephus and his friend were not keen on fully participating in this exercise, but they were reluctant to object openly.Josephus managed to survive the fratricidal circle by arranging to be the last soldier selected.He surrendered to the Romans, was adopted by a Roman family (hence the name Flavius), and eventually became a noted historian [2].He relates that it was either luck or God's Hand that saved both him and his friend (amazingly, the second-to-the-last soldier selected).Knowing where to stand relative to the starting point in order to be the last one selected is not an intuitively obvious proposition.We suspect that Josephus, who by all accounts was a clever fellow, perhaps engaged in a little experimental mathematics with pebbles in the sand to be absolutely sure of an empirical solution.By the way, if it ever comes up, stand in the 31st position or the 16th position if you can trust the guy in the 31st position.
The so-called Extended Josephus Problem [3] is a generalization of the suicide circle and considers N objects arranged in a circle where we skip over m o ects and then remove the bj bject around the circle in one direction from a fixed starting point until only one object remains.We want to know the position of the surviving object relative to the starting point.A deeper question involves the exact "kill sequence", or the de-tailed order in which the objects are eliminated.For arbitrary m and N th is a ve difficult problem in the Extended Josephus case.If instead of skipping over m objects and removing the   1 m  st, we e m objects and skip over the remov   1 m  st, we problem that is in an obvious sense complementary to an Extended Josephus Problem with parameters m and .We ill recognize the complementary problem as a   , N m T have a ma-nian Shuffle.If we save the first object and then remove m objects iteratively, we have a Texas Shuffle.Note that the simplified version of the Josephus problem in which there are N objects and the elimination rule is "skip one, kill one, repeat" is identical to the   ,1 N Texas Shuffle.There is an elegant shortcut method [4] for determining the survivor object in this case using binary arithmetic, but the justification of the method relies essentially on the details of Proposition 1.An interesting variation in a different direction concerns the study of patterns which emerge in sequences generated by reducing by various moduli [5].
The Extended Josephus problem doesn't have a simple solution, but many have tried attacking it in different ways [6].Others have tried finding algorithms [7].Recently an interesting further generalization [8] was considered where, in the setting of Josephus, each person has a set number of "lives" before they are eliminated.In this paper, we find a very simple solution to our generalization to the Josephus problem, and present it in terms of shuffling cards.Here we describe each type of shuffle.

The Australian Shuffle
Given a deck of cards numbered 1 to from the top, we subject them to the Australian Shuffle by putting the top card on the table, then putting the next card on the bottom of the deck.This is repeated until all of the cards have been placed in order, each on top of the preceding, onto the table.We want a formula for the original position of the th card placed on the table, which would be the top card of the permuted deck.More mathematically, we seek , where the permutation affects the structured shuffle.Although the Australian Shuffle formula is a sub-case of the result below for more general permutations of this nature, we think a direct proof is worth presenting separately.The Australian case lends itself to a simple proof and it gives a hint as to what the extended result might look like.

The Tasmanian Shuffle
A natural generalization of the Australian Shuffle would be to repetitively discard an arbitrary but fixed number of cards before putting one on the bottom of the deck.Since we go further south with discards before the "Down Under" move, let us call permutations of this type Tasmanian Shuffles.This introduces a complication not present in the original problem.If at some point during the execution of the Tasmanian Shuffle there are fewer cards in the surviving packet than in the number to be placed on the table, then the very next down move eliminates that surviving packet completely, and we have to decide which card is to be regarded as the last discard.Let us adopt the convention that the card on the bottom of any such final discard packet is the "last one standing".We refer to a Tasmanian shuffle that progressively eliminates $m$ cards and saves the  

Main Results
The purpose of this paper is to find the last card in each of the different shuffles proposed.The following two propositions give a simple formula for the last card.

Proposition 1 (Australian Shuffle Last Card)
With the preceding setup, the last card of the Australian Shuffle is where k is maximal subject to 2 N.  Alternatively, .

 
, N m  be the original position in a deck of cards of the last card dealt in an , and  is as large as possible, in which case Clearly the Australian Shuffle is a special case of the Tasmanian Shuffle where 1. m 

Proof of Proposition 1
Note that the first pass of the shuffle through the N cards produces a surviving deck of 2 N cards if N is even and   In any case the survivors r original order.This surviving deck is then shuffled according to the rule if N is even, since the first card of the surviving deck is placed down.But if N is odd, the parity of the rule is reversed and the first card of the surviving deck is placed under.We prove this formula using strong induction on .
and the shuffle puts the second card last on the which a with the formula.Assume that the formula is correct for all k k The induction hypothesis doe y immediately to ince the parity of the shuffling rule is reversed.We remedy this by adding a ghost card on the top of the surviving deck and applying the usual shuffling rule to the augmented surviving deck, which has

 
s not appl the surviv ck ing de , s 1 2 N  cards.The induction hypothesis still applies, since   The ghost card is immediately removed from having a the shuffle, since the down under step is initialized on it.The remaining first actual card in the surviving deck is put under, and the cards that are passed to subsequent surviving decks will be identical to those that the reversed-parity rule would have passed acting on the surviving deck without the ghost card.Now the strong induction hypothesis applies and gives the position  to the naugmented deck is 1.    As in Case (1), the position of the last card relative to the original deck is twice the position relative to k that survives the first round, so and the ca  is established.

The Texas Shuffle
, then N can be put in the form For ea type of shuffle considered, w formula for the la induction argumen find out where to stand so as to be eliminated last.Josephus supposedly knew not only the last position, but also the second to last.We think that in our case we can do even better than that.We should be able to find a formula for when each card will be discarded, that is, a formula for the permutation of the cards.The generalize-tion in [8] could also be considered in our case.
last card relative to the augmented surviving deck as Since the ghost card was put on top of the actual surviving deck, the po- card by transferring it to the bottom of the deck as an  Texas means save first, then eliminate.This variant is due to the authors attacking this problem (unknowingly) in different ways.Fortunately, this difference results in a trivial change in the formula for the last card.
Now run the Tasmanian algorithm on the augmented deck.After th first m ghost cards are removed, the situation is indistinguishable from the Texas Shuffle of just N cards.In this case, e find a simple st card, and each proof uses a strong t.Thus, in the Josephus analog we can [1] R. L. Graham, D. E. Knuth and O. Patashnik, "Concrete ch ephus Inoue and S. Tatsumi, "Josephus Prob-Institute, 2001.