Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt
- N = 10000000
- cnt = 0
- x = []
- y = []
- M = 0
- for _ in range(N):
- x1 = uniform(0,2)
- y1 = uniform(0,2)
- x2 = uniform(0,2)
- y2 = uniform(0,2)
- if (x2 - 1)**2 + (y2 - 1)**2 <= 1 and (x1 - 1)**2 + (y1 - 1)**2 <= 1:
- M += 1
- if sqrt((x2 - x1)**2 + (y2 - y1)**2) < 1:
- cnt += 1
- print(cnt / M)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement