• + 0 comments

    My Python solution with explanation:

    import math
    
    # setup situation
    bag1 = ['r']*4 + ['b']*5    # 1 pick
    bag2 = ['r']*3 + ['b']*7    # 2 picks
                                # b b r
    
    # initialize counting variables
    numerator = 0
    denominator = 0
    
    # collect event occurrences
    for X in bag1:  # 1 pick from bag1
        
        for Y1 in bag2:  # 1 pick from bag2
            bag2reduced = bag2.copy()  # create a COPY of bag2
            bag2reduced.remove(Y1)  # remove already picked element from COPY of bag2
            
            for Y2 in bag2reduced:  # 1 pick from EDITED bag2
                tup = (X, Y1, Y2)  # event
                
                if all([tup.count('r') == 1,
                        tup.count('b') == 2]):  # conditions of interest
                    numerator += 1
                
                denominator += 1
    
    gcd = math.gcd(numerator, denominator)
    
    numerator //= gcd
    denominator //= gcd
    
    print(f'{numerator}/{denominator}')