Guest User

Montecarlo

a guest
Sep 2nd, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import random
  2.  
  3. SIMULACIONES = 10000000
  4.  
  5. baraja_inicial = [0 for _ in range(13 * 4)]
  6. baraja_inicial.extend([1, 1])
  7. baraja = list(baraja_inicial)
  8. jokers = 0
  9. for _ in range(0, SIMULACIONES):
  10.     carta = random.randrange(len(baraja))
  11.     if baraja[carta] == 1:
  12.         jokers += 1
  13.         baraja = list(baraja_inicial)
  14.     else:
  15.         del baraja[carta]
  16. print("Simulaciones %d, jokers %d, porcentaje %.5f" % (SIMULACIONES, jokers,
  17.                                                        float(jokers) /
  18.                                                        float(SIMULACIONES)))
Advertisement
Add Comment
Please, Sign In to add comment