You are viewing a single comment's thread. Return to all comments →
from fractions import Fraction def urns(a): prob = [Fraction(x[0], sum(x)) for x in a] prob_c = [1 - x for x in prob] n = len(a) ans = 0 for i in range(n): p = prob_c[i] * prob[(i + 1) % n] * prob[(i + 2) % n] ans += p return ans b = [[4, 3], [5, 4], [4, 4]] print(urns(b))
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Basic Probability Puzzles #3
You are viewing a single comment's thread. Return to all comments →