We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 2: More Dice
Day 2: More Dice
Sort by
recency
|
65 Discussions
|
Please Login in order to post a comment
a = [{a, b} for a in range(1, 7) for b in range(1, 7) if sum({a, b}) == 6] b = [{a, b} for a in range(1, 7) for b in range(1, 7)] print(len(a)/len(b) * 30/36)
lol
dice1 = [1,2,3,4,5,6] dice2 = [1,2,3,4,5,6] total = len(dice1) * len(dice2) total_possibilities = 0
for i in range(len(dice1)): for j in range(len(dice2)): if (dice1[j] + dice1[i]) <= 9: total_possibilities = total_possibilities + 1 print("{0} + {1} = {2}".format(dice1[i], dice2[j], (dice1[j] + dice1[i])))
probability = total_possibilities / total print("Probability: {0}/{1} = {2}".format(total_possibilities,total,probability))
Python
There are 6 number of ways for the sum of two dices to be 6: (1 + 5) (5 + 1) (2 + 4) (4 + 2) (3 + 3) (3 + 3). So we eliminate the last two since both dices are the same number. So the probability of getting the sum of 6 where the two dices are not the same = 4/36 (36 is the total outcomes of both dices)