Problem 1512. Clock Solitaire
Many card players will be familiar with the game of Clock Solitaire. Briefly, the player sets up by creating thirteen piles of four face-down cards at random, each associated with one of the ranks ace through king. Beginning with the top card in the king's pile, the player places the drawn card face up beneath its home pile, and draws a new card from the top of that same pile. Play continues until the fourth king is drawn. If all cards are face up in their home piles at this time, the game is a winner.
Since clock solitaire is a purely deterministic game, a computer can easily be programmed to play. For this problem, you will write a function that takes a deck and reports whether or not it is a winning configuration. More specifically, the input will be some permutation of the integers 1:52, where 1:13 represent the ace through king of clubs, 14:26 the ace through king of diamonds, 27:39 the hearts, and 40:52 the spades. Assume that the cards are formed into 13 piles by taking the first four cards as the ace pile, next four as the deuce pile, etc. Output is a single scalar boolean indicating whether the game will be won using this deck.
Armed with this function, one can determine empirically what the win rate is for randomly shuffled decks. See if you can find out!
Solution Stats
Problem Comments
-
1 Comment
Please add a test case that kills my invalid leading solution.
I misinterpreted the wiki page for sequencing which I thought was random choice to produce a 1 in 13 probability.
Solution Comments
Show commentsGroup

Strings II
- 21 Problems
- 41 Finishers
- Eliminate Polysyllabics: Long live short words!
- Alternately upper-lower case
- Morse Code Generator! Try it!
- Is the paranthesis sequence balanced ?
- Simple Decoder Ring
- Join Strings with Multiple Different Delimiters
- Is the paranthesis sequence balanced ?
- Count letters occurence in text, specific to words with a given length.
- Convert Two Character String into a Binary Vector
- Kryptos - CIA Cypher Sculpture: Vigenere Encryption
- Kryptos - CIA Cypher Sculpture: Vignere Decryption
- Mean and standard deviation of times in string
- How many digits are there?
- ABBREVIATION
- Make a list string
- Generate a melodic contour string matrix
- Morse Code Generator! Try it!
- NO _________ ALLOWED....
- Backslang, odds are you used it at some point in time...
- Simple Caesar Cypher - shift encrypt a message given an index number
- Split a given string from the first instance of a given character
- Concatenate strings
- most frequent character
- Alternately upper-lower case
Problem Recent Solvers37
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!