Sort by

recency

|

83 Discussions

|

  • + 0 comments

    Failled 3 times without knowing i wouldnt have another try ..ever . Maybe it would be better to warn users about it .. OR after 3 errors , reset the challenge with another question and other parameters .. Or even better just forget about the multiple choice.. And let us code .

  • + 1 comment

    The given answer choices don't match the real answer; should be 1/9

  • + 0 comments
    # Dice # 1
    dice_1 = [1, 2, 3, 4, 5, 6]
    
    # Dice # 2
    dice_2 = dice_1.copy()
    
    less_than_10 = 0
    all_outcomes = 0
    
    # Iterate through
    for v1 in dice_1:
        for v2 in dice_2:
    # add 1 for every pair to all_outcomes
            all_outcomes += 1
            if v1 + v2 < 10:
    # add 1 for pairs that summed up to 9 or below to less_than_10.
                less_than_10 += 1
    
    prob_less_than_10 = less_than_10 / all_outcomes
    print(prob_less_than_10)
    
  • + 0 comments

    from itertools import product from fractions import Fraction

    P = list(product([1, 2, 3, 4, 5, 6], repeat=2))

    N = sum(1 for x in P if sum(x) <= 9)

    print(Fraction(N, len(P)))

  • + 1 comment
    lst1=[1,2,3,4,5,6]
    lst2=[1,2,3,4,5,6]
    count=0
    count_of_occurences=0
    for i in range(0,len(lst1)):
        for j in range(0,len(lst2)):
            if lst1[i]+lst2[j]>0:
                count_of_occurences+=1
            if lst1[i]+lst2[j]<=9:
                count+=1
    
    print(count)
    print(count_of_occurences)