You are viewing a single comment's thread. Return to all comments →
from itertools import combinations from fractions import Fraction n = 3 k = 2 p_r = [Fraction(4,7), Fraction(5,9), Fraction(4,8)] p_b = [Fraction(3,7), Fraction(4,9), Fraction(4,8)] total = Fraction(0,1) for i,j in combinations(range(n), k): remaining_option = next(x for x in range(n) if x not in (i, j)) total += p_r[i] * p_r[j] * p_b[remaining_option] print(total)
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 →