You are viewing a single comment's thread. Return to all comments →
from fractions import Fraction from itertools import combinations bag_1=['r','r','r','r','b','b','b','b','b'] bag_2=['r','r','r','b','b','b','b','b','b','b'] all_pairs=[] num=0 for item1_bag_1 in (bag_1): for item2_bag_2,item3_bag2 in (combinations(bag_2,2)): all_pairs.append((item1_bag_1,item2_bag_2,item3_bag2)) for bbr in all_pairs: if bbr.count('r')==1 and bbr.count('b')==2: num+=1 print(Fraction(num,len(all_pairs)))
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Basic Probability Puzzles #4
You are viewing a single comment's thread. Return to all comments →