alone in Napoli
This article is originally published at https://xianblog.wordpress.com
A combinatorics puzzle from The Riddler about a Napoli solitaire where 4 x 10 cards numbered from 1 to 10 are shuffled and the game is lost when a number (1,2, or 3) is equal to its position modulo 3 (1,2 or 3). A simple R code shows that the probability of winning is around 0.00831:
N=40 for(t in 1:1e6)F=F+!sum(!(sample((1:N)%%10)-(1:N)%%3))
ChatGPT bends over backward to achieve this figure! Now, the exact probability can be found by combinatorics. While there are 40! ways of permuting the 40 cards, those missing the coincidences are
multiplied by 4!4!4!28! (which I initially forgot), resulting in 0.00831:
for(i in 0:4)for(j in 0:4)for(k in 0:4) F=F+exp(lchoose(13,i)+lchoose(13,4-i)+3*lfactorial(4)+ lchoose(14,j)+lchoose(13-i,4-j)+lfactorial(28)+ lchoose(14-j,k)+lchoose(9+i,4-k)-lfactorial(40))
Thanks for visiting r-craft.org
This article is originally published at https://xianblog.wordpress.com
Please visit source website for post related comments.