Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import random as r
- T = 200
- rand = lambda: r() * T
- t1 = 25
- t2 = 40
- total = 0
- only_a = 0
- only_b = 0
- both = 0
- attempts = 100000000
- for _ in range( attempts ):
- a = rand()
- b = rand()
- #print( a, a+t1, b, b+t2 )
- #print( a + t1 > b, b + t2 > a)
- if a + t1 < b:
- only_a +=1
- elif b + t2 < a:
- only_b +=1
- else:
- both +=1
- total += 1
- print( total )
- print( 'A|B', 100* only_a / total + 100* only_b / total )
- print( 'A&B', 100* both / total )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement