fantho69

A12345678910JQK_simulazione

Jan 25th, 2026
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | Science | 0 0
  1. from random import shuffle
  2. K=13
  3. def monte_carlo():
  4.     mazzo = []
  5.     for valore in range(1,K+1):
  6.         mazzo += [valore]*4
  7.     shuffle(mazzo)
  8.     obiettivo = 1
  9.     for carta in mazzo:
  10.         if carta == obiettivo:
  11.             obiettivo += 1
  12.             if obiettivo == K+1:
  13.                 return True
  14.     return False
  15.  
  16. # codice eseguibile
  17.  
  18. N = 100000
  19. goal = 0
  20. for _ in range(N):
  21.     if monte_carlo():
  22.         goal += 1
  23. print(goal / N)
Advertisement
Add Comment
Please, Sign In to add comment