#Monte Carlo Estimation of Pi
#Randomly generate values between -1 and 1.
#Count how many generated points are within unit square and unit circle
#The ratio of how many are in unit circle to unit square is equal to pi / 4 (i.e. the ratio of their areas)

import random
random.seed(1)

iterations = 1_000_000
circle_count = 0
square_count = 0

for _ in range(iterations):
  x_val = random.uniform(-1,1)
  y_val = random.uniform(-1,1)
  euclidean_dist = (x_val ** 2 + y_val ** 2) ** 0.5
  if euclidean_dist <= 1:
    circle_count += 1
  square_count += 1

pi_estimation = 4 * circle_count / square_count
print(pi_estimation)
