Sort by

recency

|

13 Discussions

|

  • + 0 comments

    There are two scenarios * The probability of picking a white ball from X (5/9) and then picking a black ball from Y (6/14) is (5/9) * (6/14) * The probability of picking a black ball from X (4/9) and then picking a black ball from Y (7/14) is (4/9) * (7/14)

    The final probablity is the sum of the two conditions above.

  • + 0 comments
    from fractions import Fraction
    
    x = ['w']*5 + ['b']*4
    y = ['w']*7 + ['b']*6
    
    def black_probability(x,y):
        return (Fraction(x.count('w') * y.count('b'), len(x) * (len(y)+1)) 
                + 
                Fraction(x.count('b') * (y.count('b')+1), len(x) * (len(y)+1)))
        
    print(black_probability(x,y))
    
  • + 0 comments
    from fractions import Fraction
    
    X = ['w']*5 + ['b']*4
    Y = ['w']*7 + ['b']*6
    count=0
    visited=0
    
    for i in X:
        tem=Y+[i]
        #print(tem)
        for j in tem:
            if j=="b":
                count+=1
            visited+=1
            
    print(Fraction(count,visited))
    
  • + 0 comments

    What is the format of input? Why there is no explanation? It took time to understand that values should be hardcoded.

  • + 0 comments

    Another way to think about this logically:

    P(W) = {7+(5/9)}/14

    P(B) = {6+(4/9)}/14

    P(B) = 29/63