clock_solitaire_simulation, a Python code which simulates the game of clock solitaire. The deck is dealt into 13 piles of 4 cards each. Repeatedly, the top card a pile is removed, and its rank indicates the next pile to consider. Game continues until an empty pile is reached. The game is won if all piles are empty. The quantity of interest is the probability of winning.

Knuth showed that the probability of winning is exactly 1/13.


The computer code and data files described and made available on this web page are distributed under the MIT license


clock_solitaire_simulation is available in a MATLAB version and an Octave version and a Python version.

Related Data and codes:


python_simulation, a Python code which uses simulation to study card games, contests, and other processes which have a random element. Usually, the purpose is to try to predict the average behavior of the system over many trials.


Source Code:

Last revised on 16 November 2022.