Given two jars of red and blue balls, find the probability of choosing a red ball from Jar 1 after going through the steps.
Step 1: Choose a random ball from Jar 2 and add it to Jar 1
Step 2: Choose a random ball from Jar 1
Step 3: Calculate the probability of the final ball being red
Example:
Given inputs for Jar 1 and Jar 2
Jar 1: (r1,b1) = (2,7)
Jar 2: (r2,b2) = (5,5)
Choose a ball from Jar 2 and add it to Jar 1.
_Note: Jar 1 could now have either 3 blue and 7 red or 2 blue and 8 red._
Taking into consideration both possibilities, the likelihood of the final ball being red is 0.25 .
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers69
Suggested Problems
-
How to find the position of an element in a vector without using the find function
2822 Solvers
-
998 Solvers
-
What is the distance from point P(x,y) to the line Ax + By + C = 0?
560 Solvers
-
Implement simple rotation cypher
1099 Solvers
-
Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
267 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
I can't submit a solution to this problem. I have the message : There was an issue submitting your solution (Remove inappropriate content. For guidelines, see About Cody). I don't understand why, everything is classic in my code and works fine on my computer. I even can't pass the tests. Any idea ?
It is a bug in Cody. We are working on fixing it. I will let you know as soon as we fix it.