## L224: Solution
## SXD 224 

# at_least_once_in(N,p) returns 1-(1-p)**N, which is
# the probability of getting at least once a given
# event of probability p in N independent observations 
from cdi import at_least_once_in

# Probability of getting 6 at least once
# in 4 throws of a fair die

p = 1/6
N = 4

P = at_least_once_in(N,p)
print("P=",P)


# Probability of getting a repeated 6 at least once
# in 24 throws of two fair dice

p = 1/36
N = 24

P = at_least_once_in(N,p)
print("P=",P)

# What is the least value of N such that
# 1-(1-p)**N > 0.5177

while at_least_once_in(N,p) < at_least_once_in(4,1/6):
    N += 1
print("N =",N)





