Sort by

recency

|

71 Discussions

|

  • + 0 comments

    Tackling complex problems, like some of the ones on HackerRank, can be super rewarding but also a bit overwhelming at times, especially when every detail has to be spot-on. I had a similar experience when I worked on organizing a large event with tons of moving parts—it needed flawless execution from start to finish. I ended up working with event companies in Miami and their attention to every tiny detail was impressive. It kind of reminded me of debugging a tricky code problem; they made sure everything was aligned perfectly, which made the whole event a success. Having experts like that can really save time and bring peace of mind, no matter the challenge!

  • + 0 comments
    # Probabilities
    urn_x = {'R': 4/7, 'B': 3/7}
    urn_y = {'R': 5/9, 'B': 4/9}
    urn_z = {'R': 1/2, 'B': 1/2}
    
    # Scenarios
    scenarios = [
        ['R', 'B', 'R'],  # R from X, B from Y, R from Z
        ['B', 'R', 'R'],  # B from X, R from Y, R from Z
        ['R', 'R', 'B']   # R from X, R from Y, B from Z
    ]
    
    # Calculate probabilities for each scenario
    total_probability = 0
    for scenario in scenarios:
        probability = 1
        for i in range(3):
            if i == 0:
                probability *= urn_x[scenario[i]]
            elif i == 1:
                probability *= urn_y[scenario[i]]
            else:
                probability *= urn_z[scenario[i]]
        total_probability += probability
    		
    print("The probability of drawing 2 red balls and 1 black ball is:", total_probability)
    
  • + 0 comments
    from fractions import Fraction
    from math import prod
    def probabilities(x, y, z):
        r1,r2 = Fraction(x[0], sum(x)),Fraction(y[0], sum(y))
        b1,b2 = Fraction(x[1], sum(x)),Fraction(y[1], sum(y))
        r3,b3 = Fraction(z[0], sum(z)),Fraction(z[1], sum(z))
        return [(r1,r2,b3),(r1,b2,r3),(b1,r2,r3)]
    
    def calc_prob(x, y, z):
        to_mult = probabilities(x, y, z)
        prob = Fraction(0,1)
        for m in to_mult:prob += prod(m)
        return prob
    
    x,y,z= (4, 3),(5, 4),(4, 4)
    
    probability = calc_prob(x, y, z)
    print(f"{probability.numerator}/{probability.denominator}")
    
  • + 1 comment
    from itertools import product 
    from fractions import Fraction
    
    P = list(product([1]*4+[0]*3, [1]*5+[0]*4, [1]*4+[0]*4))
    
    N = sum(1 for x in P if sum(x)==2)
    
    print(Fraction(N, len(P)))
    
  • + 0 comments

    Can you count probability of success in wedding photography aukland? I need fail and success both probability but it's not valid.