Long Playing Card Configurations in Beggar My Neighbor

Long Playing Card Configurations in Beggar My Neighbor

Warning: This is probably one of the most boring pages ever created. I generated the data for this page as part of a contest I entered in 1991. On the slight chance that anyone is ever interested I figured I might as well put it on the net. Incidentally, I came in second place in this contest and won a year's subscription to a journal.

Beggar My Neighbor (also know as Beggar Thy Neighbor or Beggar Your Neighbor) is a British card game for two people. It's similar to the kid's card game War, where the winner is pre-determined by the deal and no skill is involved. The game is played by Pip and Estella in the book "Great Expectations" by Charles Dickens.


The rules are very simple and are summarized here:

The Setup:

A standard deck of cards is fully dealt between the two players. A person is chosen to start play and from then on the players alternate.

The Play:

The person whose turn it is (player1) takes the top card off of his deck and places it face up in the middle of the playing area onto the trick stack. If this card is a normal card (from two to ten), play passes to the next player (player2).

If the card is a court card (Jack, Queen, King, or Ace), then things get a bit more interesting. Player2 now must place up to a predetermined number of cards on the trick stack. The number is determined by the court card played by the previous player (one for a Jack, two for a Queen, three for a King, four for an Ace). He plays cards one by one off of his deck. If each one is a normal card, then as soon as he's done playing these cards, his opponent (player1) takes the trick stack, places it on the bottom of his deck, and plays again. If while playing the cards, player2 plays a court card himself, then the other player (player1) is in the same position as player2 was after player1 played the first court card.

The first person who runs out of cards is the loser, and the other player takes any cards in the trick stack.

Another explanation of the rules is available at a Wikipedia where the associated with the book "Great Expectations" is noted.


In November of 1991, Chris Long initiated a contest to see who could find the initial hand that would go the highest number of rounds before the game ended. A round was counted whenever the trick stack was picked up. I believe his interest was to find if it was possible for there to be a card configuration where there was a cycle so that the game would never end.

I wrote a program to churn through random hands, playing them out and keeping track of how many rounds each resulted in. The contest ran for about 6 weeks, and I managed to find one that went 703 rounds. It turned out that I came in second to someone who found one that went 706 rounds. I later improved my program a little and have run it occasionally in the background on my computer. I have since found two initial deck configurations that result in a game going 769 rounds and lots of others that are shorter than that but still very long. I'm quite sure that the 769 round games are the longest ever found. I thought I'd make them available on the net on the off chance that anyone's interested.

I've actually run two separate programs. One generates purely random hands, while the other generates hands that have about the same number of court cards in each hand. The second tends to generate somewhat longer running deals on average.

With the program that generated purely random hands, I kept track of the length in rounds of each game. After analyzing 369,400,000,000 games, here are some interesting statistics: The most common number of rounds for a game is 11, which happens 2.70150068% of the time. In 0.00001602% of the time, the game ends after only one round! I've put an example of one of these one round games at the bottom of this page. Just over 50% of the time, the game ends after from 6 to 28 rounds. Incidentally, the total number of possible deals that are distinct from the game's point of view (swapping a 9 of hearts and a 2 of clubs wouldn't change the outcome) is 653,534,134,886,878,245,000. It's equal to 52!/(4!*4!*4!*4!*36!), which is the number of permutations of 52 cards divided by the number of permutations of the aces and of the kings, and of the queens, and of the jacks, and of the other cards.

In total, my programs played through 738,640,000,000 randomly generated games. Below are all of the ones I found where the resulting games go on for 775 rounds or more. The deck order is top to bottom. Aces, Kings, Queens, and Jacks are denoted by 'A', 'K', 'Q', 'J', respectively, and all other cards are denoted by a '0'.

Tricks taken   = 960
Winning player = 1
Player 1 Deck  = A0QK000000Q0000KA00000J000
Player 2 Deck  = 0JAK0000A00Q0000J000QJ00K0

Tricks taken   = 905
Winning player = 1
Player 1 Deck  = 00K0000Q000JA0000000K0J000
Player 2 Deck  = JA0J0Q0000000A0QQK0K00000A

Tricks taken   = 873
Winning player = 2
Player 1 Deck  = 000Q00QJ0A00000000Q0QA000K
Player 2 Deck  = 00A00A0K00KKJJ000000000J00

Tricks taken   = 867
Winning player = 1
Player 1 Deck  = 00000JQ00J000000KK00K0QK0J
Player 2 Deck  = 00000A00000000A0A0QA0Q000J

Tricks taken   = 861
Winning player = 2
Player 1 Deck  = 0K00J0000Q0J0A0A00000000QA
Player 2 Deck  = K00K0QK0Q000A00000J0J00000

Tricks taken   = 852
Winning player = 2
Player 1 Deck  = A0000AJ0K0000QAJ0Q000000Q0
Player 2 Deck  = QK0A0000000000K0JK0000000J

Tricks taken   = 848
Winning player = 1
Player 1 Deck  = 00J0A0000000K000Q0A00Q00AK
Player 2 Deck  = 00K0K00Q0000J000000J0QAJ00

Tricks taken   = 846
Winning player = 2
Player 1 Deck  = 0000A000JQ000Q00A00J00J000
Player 2 Deck  = 0K00Q000J000KA00K00000KQ0A

Tricks taken   = 823
Winning player = 2
Player 1 Deck  = AK00J00A00J000000K0Q00000A
Player 2 Deck  = 00000J00Q0AJ0K0KQ000000Q00

Tricks taken   = 822
Winning player = 1
Player 1 Deck  = 000QA000000QJ000Q00K00QA00
Player 2 Deck  = 000000AK0J00000KJ00K0JA000

Tricks taken   = 817
Winning player = 1
Player 1 Deck  = Q000000Q00AQ0000JJK00000K0
Player 2 Deck  = 000000KA0J0A00K00J00AQ0000

Tricks taken   = 816
Winning player = 1
Player 1 Deck  = 0QJ000K00JK0A000A00Q00000Q
Player 2 Deck  = 00Q00K0000000000K0JA00AJ00

Tricks taken   = 816
Winning player = 1
Player 1 Deck  = Q00K00000000J00KK0AJ000A00
Player 2 Deck  = 00A0000Q0000K000JJ00QA0Q00

Tricks taken   = 813
Winning player = 1
Player 1 Deck  = AKA0000000QJ00000A0K00A000
Player 2 Deck  = 00Q0JQ000000000Q00KJK0000J

Tricks taken   = 813
Winning player = 2
Player 1 Deck  = 00000J00J000A00J00QA0K0KA0
Player 2 Deck  = 0000Q000000000QAJ0K00KQ000

Tricks taken   = 811
Winning player = 1
Player 1 Deck  = 00A0A00QJ0000Q000A0J00K000
Player 2 Deck  = 00AK0J00KQ000000Q0K000000J

Tricks taken   = 810
Winning player = 1
Player 1 Deck  = 0000Q00K0Q0K0A000J0K000QA0
Player 2 Deck  = JK00000A0J00Q0J0A000000000

Tricks taken   = 810
Winning player = 2
Player 1 Deck  = 0K0000KJ0000Q00KJ0000A000Q
Player 2 Deck  = K00000000AQQ0A00J000J000A0

Tricks taken   = 809
Winning player = 2
Player 1 Deck  = QK0000000Q0000KAJ00J000QA0
Player 2 Deck  = 000000000JK0A00Q0A0J000K00

Tricks taken   = 804
Winning player = 2
Player 1 Deck  = KJ00K000Q0000QJ00A000A0000
Player 2 Deck  = K0A0000JJ0000KQA000Q000000

Tricks taken   = 802
Winning player = 2
Player 1 Deck  = 0KJ00AQJ00A000000000Q000J0
Player 2 Deck  = 000JA000Q00Q0KKA0K00000000

Tricks taken   = 800
Winning player = 2
Player 1 Deck  = KK0000000Q0000000A0J00Q0J0
Player 2 Deck  = 00J00Q00A00KK000JQ000A0A00

Tricks taken   = 791
Winning player = 2
Player 1 Deck  = 0J0A0J0000000K0AKKQ0000000
Player 2 Deck  = 0000000Q0QAKJ000000Q000JA0

Tricks taken   = 790
Winning player = 2
Player 1 Deck  = 00000KJ00KQ0Q00000J00A00A0
Player 2 Deck  = 0J00A00K000AK0Q000Q00000J0

Tricks taken   = 781
Winning player = 1
Player 1 Deck  = 0000Q00K0Q0000A0A00JA00KQ0
Player 2 Deck  = 000J000000QA0000000J00K0JK

Tricks taken   = 780
Winning player = 1
Player 1 Deck  = 00Q0000A00QQ0000J00K0KK000
Player 2 Deck  = JA0A0000Q0K00000J0AJ000000

Tricks taken   = 779
Winning player = 1
Player 1 Deck  = 00K000Q0A0Q000J00000AQ0000
Player 2 Deck  = K00A0K00J0AKJ00000Q00000J0

Tricks taken   = 776
Winning player = 1
Player 1 Deck  = 00000AAJ0000000Q0000K0000K
Player 2 Deck  = 0000AQJ000QJKK000A000J0Q00

Here are four examples of configurations where one of the players wins by taking all of the other's cards in the first round:

Tricks taken   = 1
Winning Player = 1
Player 1 deck  = 0000000K00Q000J00Q00JQK000
Player 2 deck  = 00000000K0AA0AQJA000000KJ0

Tricks taken   = 1
Winning Player = 1
Player 1 deck  = 0000000000000KA00J0JJ0K00Q
Player 2 deck  = 0000000000000Q00AKKA0AQJQ0

Tricks taken   = 1
Winning Player = 2
Player 1 deck  = 0000000000KA00Q00KAAQ0J00Q
Player 2 deck  = 000000000J00J00KA0Q0K000J0

Tricks taken   = 1
Winning Player = 2
Player 1 deck  = 0000000000A0Q00JAKKQ00A0J0
Player 2 deck  = 000000000000Q0KK0J0J0Q0A00

16,302 visits (1 today, 11 this week, 32 this since October 19, 1999.

Back to my homepage.

Copyright 1999 by Truman Collins
For comments, email: Truman Collins (truman@tkcs-collins.com)
Most recent update: November 24, 2013
http://www.tkcs-collins.com/truman/byn/byn.shtml