Sort by

recency

|

46 Discussions

|

  • + 0 comments

    from math import gcd

    def calulate_probability(max_sum,side=6): total_outcome=side * side favourable = 0

    for i in range(1,side+1):
        for j in range(1,side+1):
            if i + j <=max_sum:
                favourable += 1
    
    divisor = gcd(favourable,total_outcome)
    numerator= favourable//divisor
    denominator = total_outcome//divisor
    
    return f"{numerator}//{denominator}"
    

    x=int(input()) print("total_outcome:",calulate_probability(x))

  • + 0 comments

    Check out thia link for full solution with AI and ML use cases, https://youtu.be/0uIdaXmkMSE?si=v4KG2m63H1D45iui

  • + 0 comments

    from math import gcd total_outcomes = 6 * 6 favorable = 0 for i in range(1, 7): for j in range(1, 7): if i + j <= 9: favorable += 1 print(f"{favorable // gcd(favorable,total_outcomes)} / {total_outcomes//gcd(favorable,total_outcomes)}")

  • + 1 comment

    Quite dissapointed with the instructions of the problem statement , it is clearly mentioned to write a plain text , but we hav eto use print statement if it were python .!! SMH

  • + 0 comments

    from math import gcd

    def proba(n, k): count=0 dice1=range(1, n+1) dice2=range(1, n+1) for i in dice1: for j in dice2: if i + j <= k: count+=1 nbr_event = n*n

    pgcd=gcd(count, nbr_event)
    
    num=count//pgcd
    denum= nbr_event//pgcd
    
    return f"{num}/{denum}"
    

    proba(6, 9)