Day 3: Drawing Marbles HackerRank Solution


Day 3: Drawing Marbles HackerRank Solution
Source : https://www.hackerrank.com/challenges/s10-mcq-6

Objective
In this challenge, we're reinforcing what we've learned today. In case you've missed them, today's tutorials are on Conditional Probability and Combinations and Permutations.

Task
A bag contains red marbles and blue marbles. Then, marbles are drawn from the bag, at random, without replacement. If the first marble drawn is red, what is the probability that the second marble is blue?

1 / 12
7 / 12
1 / 6
2 / 3


Source : https://www.hackerrank.com/challenges/s10-mcq-6


Solution


github.com/RodneyShag
Answer: 2/3
After drawing the first marble, we are left with 2 red marbles and 4 blue marbles.
Now we calculate the probability of drawing a blue marble as :
= (# of blue marbles) / (total # of marbles)
= 4 / (2 + 4)
= 2 / 3

No comments:

Post a Comment