## Counting solitaire

Arrangements, combinations and permutations, probability, ...
guana
Posts: 10
Joined: Mon Mar 17, 2008 3:31 pm

### Counting solitaire

Using a single deck (52 cards) the rules of the solitaire game are as follows.

1. Draw a card, counting "one". Draw the next card, counting "two". Keep counting and drawing cards until you reach thirteen and start again from one. (1 = Ace, .. 11 = Jack, 12 = Queen, 13 = King)
2. If at any point the number you count matches the card drawn, the game is lost.
3. The game is won if you can count through the whole deck.

How many deck combinations out of 52! lead to a winning game in this game of solitaire?
wrongrook
Posts: 529
Joined: Sat Oct 17, 2009 10:39 pm

### Re: Counting solitaire

using the Python code (0.03seconds):

Code: Select all

def derange_cards(J,C):
if C==0: return J==0
return sum(nCr(4,k)*nCr(4,j)*nPr(J,j)*nPr(J,k)*derange_cards(J-j+4-k,C-4) for j in range(min(4,J)+1) for k in range(min(4,J)+1))
derange_cards=Memoize(derange_cards)
print derange_cards(0,52)

I found it very helpful to consider placing all the cards of the same rank at the same time, and keep track of how many gaps I have left (J) in placing the cards so far. For each rank, j is how many gaps to fill in, and k is how many of the spare cards to use up.
TammaraBa23
Posts: 3
Joined: Tue Oct 14, 2014 5:09 am

### Re: Counting solitaire

Cool game. Best of luck everyone.
Tammara
Check this amazing dream dictionary site which discusses different dreams, you can visit the dream site at dreamdictionarynow is has a dream dictionary a-z.