Day 2: Basic Probability HackerRank Solution


Day 2: Basic Probability HackerRank Solution
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 .

<p>2 / 3</p>
<p>5 / 6</p>
<p>1 / 4</p>
<p>1 / 6</p>


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