Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First - Pearls in the box solution in Clear category for Pearls in the Box by AQiccl135
def checkio(pearls, n, count = 1):
"""
This function calculates how many black pearls and how many white
pearls there are after each possible turn. After 'n' turns have been
played, the likelihood of drawing a white pearl is calculated.
"""
size = len(pearls)
b, w = pearls.count('b'), pearls.count('w')
while count < n:
temp_b, temp_w = b, w
b = temp_b * size - temp_b + temp_w
w = temp_w * size - temp_w + temp_b
count += 1
return w / (b + w)
May 4, 2015
Comments: