Advertisement
qberik

Untitled

Apr 6th, 2023
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. from random import random as r
  2.  
  3. T = 200
  4.  
  5. rand = lambda: r() * T
  6.  
  7. t1 = 25
  8. t2 = 40
  9.  
  10.  
  11. total = 0
  12. only_a = 0
  13. only_b = 0
  14. both = 0
  15. attempts = 100000000
  16.  
  17. for _ in range( attempts ):
  18.  
  19. a = rand()
  20. b = rand()
  21.  
  22. #print( a, a+t1, b, b+t2 )
  23. #print( a + t1 > b, b + t2 > a)
  24.  
  25. if a + t1 < b:
  26. only_a +=1
  27. elif b + t2 < a:
  28. only_b +=1
  29. else:
  30. both +=1
  31. total += 1
  32.  
  33.  
  34. print( total )
  35. print( 'A|B', 100* only_a / total + 100* only_b / total )
  36. print( 'A&B', 100* both / total )
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement