Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Pearls in the Box by tokiojapan55
def checkio(marbles: str, step: int) -> float:
n = len(marbles)
calc = lambda w, s: ((w and w * calc(w - 1, s - 1)) + (n > w and (n - w) * calc(w + 1, s - 1)) if s else w) / n
return round(calc(marbles.count('w'), step - 1), 2)
Jan. 9, 2025