Stateless card dealing

How many times have you had somebody deal a hand of cards and then say "um, everybody count your cards".  A common reason for this to happen is that the dealer loses count of how many cards are dealt. 

For example, dealing cards to 4 players may look like:


The problem is that after a few cards, it's not obvious from inspection how many cards are on the table and so you have to keep track of it mentally. In computer-speak, you need to keep state.


An alternative way to deal cards is like this:



In this case, the layout of cards at the south end makes it very easy to track ("recompute") how many cards have been dealt, thus avoiding the dealer needing to track it themselves and greatly reducing the odds of losing count. 



In fact, you could extend this protocol such that you could feasibly switch dealers in the middle of the dealing process. If the dealer arranged all player's cards in block form like so:


it would be instantly clear to another dealer where to resume (on the east hand). This would also catch other categories of mistakes like the dealer accidentally skipping somebody.


Practical applications?

1. This same technique applies to algorithm design. The more state that you need to keep track of, the more likely the state is to get out of sync and be wrong. And the harder problems can be to diagnose.

2. Try dealing cards this way. While you may be laughed and mocked, you at least won't lose count.

Comments (0)

Skip to main content