Source : https://www.hackerrank.com/challenges/s10-mcq-2
Objective
In this challenge, we practice calculating probability. We recommend you review the previous challenge's Tutorial before attempting this problem.
Task
In a single toss of fair (evenly-weighted) six-sided dice, find the probability that the values rolled by each die will be different and the two dice have a sum of .
Source : https://www.hackerrank.com/challenges/s10-mcq-2
Solution
github.com/RodneyShag | |
Answer: 1/9 | |
There are 6 possibilities on each die. On 2 dice, there are 6 * 6 = 36 possibilities | |
There are 4 cases that match the desired criteria: (1,5) (5,1) (2,4) (4,2) | |
This gives us a probability of 4/36 = 1/9 |
No comments:
Post a Comment