fork download
  1. # your code goes here
  2. import random
  3.  
  4. rate = 0.006
  5. limit = 80
  6.  
  7. sim = 10000
  8. cnt = 0
  9. item = 0
  10. sum = 0
  11. min = 999
  12. max = 0
  13. dist = [0]*160
  14. for x in range(sim):
  15. while item<2:
  16. for i in range(limit):
  17. if random.random() < rate:
  18. item += 1
  19. cnt += i+1
  20. break
  21. if i == limit-1:
  22. item += 1
  23. cnt += limit
  24. if cnt>max:
  25. max = cnt
  26. elif cnt<min:
  27. min = cnt
  28. sum += cnt
  29. dist[cnt-1] += 1
  30. item = 0
  31. cnt = 0
  32.  
  33. print("avg:%d\nmax:%d\nmin:%d" %(sum/sim, max, min))
  34. print(dist)
Success #stdin #stdout 0.26s 11652KB
stdin
Standard input is empty
stdout
avg:126
max:160
min:2
[0, 1, 0, 4, 0, 4, 1, 2, 0, 6, 2, 1, 5, 5, 2, 3, 3, 5, 5, 5, 7, 3, 12, 11, 8, 10, 10, 8, 10, 10, 12, 10, 10, 11, 11, 9, 11, 15, 8, 8, 12, 8, 8, 10, 13, 12, 10, 11, 9, 8, 12, 18, 16, 10, 11, 11, 11, 16, 25, 11, 13, 18, 15, 22, 12, 20, 15, 18, 22, 20, 11, 20, 13, 21, 12, 21, 13, 22, 22, 16, 75, 80, 104, 110, 93, 84, 109, 88, 85, 83, 100, 107, 79, 97, 85, 69, 85, 86, 84, 74, 79, 75, 73, 81, 66, 94, 71, 78, 62, 59, 51, 74, 60, 72, 73, 78, 76, 82, 53, 64, 66, 68, 58, 72, 70, 82, 65, 55, 51, 53, 41, 64, 74, 47, 58, 62, 62, 60, 57, 53, 64, 44, 57, 54, 53, 47, 48, 59, 53, 55, 40, 42, 52, 48, 44, 51, 37, 52, 42, 3806]