Source : https://www.hackerrank.com/challenges/s10-mcq-1
Objective
In this challenge, we practice calculating probability. Check out the Tutorial tab for a breakdown of probability fundamentals!
Task
In a single toss of fair (evenly-weighted) six-sided dice, find the probability that their sum will be at most .
Source : https://www.hackerrank.com/challenges/s10-mcq-1
Solution
github.com/RodneyShag | |
Answer: 5/6 | |
There are 6 possibilities on each die. On 2 dice, there are 6 * 6 = 36 possibilities | |
There are 6 cases where sum >= 10: (4,6), (5,5), (5,6), (6,4), (6,5), (6,6) | |
This gives us probability(sum >= 10) = 6/36 = 1/6 | |
That means probability(sum <= 9) = 1 - 1/6 = 5/6 |
No comments:
Post a Comment