We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Artificial Intelligence
- Probability & Statistics - Foundations
- Day 2: Basic Probability Puzzles #4
- Discussions
Day 2: Basic Probability Puzzles #4
Day 2: Basic Probability Puzzles #4
Sort by
recency
|
11 Discussions
|
Please Login in order to post a comment
My Python solution with explanation:
Python 3 code
what is the problem i couldn't understand please help me: import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*; public class Prob {
public static void main(String[] args) {int x[]; int y[]; Scanner in = new Scanner(System.in);
for(int i=0;i<2;i++) { x[i]=in.nextInt(); } for(int i=0;i<2;i++) { y[i]=in.nextInt(); } int prob1,prob2; prob1 = x[1] * (y[1]+1); prob2 = (x[0]+x[1])*((y[0]+y[1])+1);
System.out.println(prob1+"/"+prob2); } }
Here's how I approached to the solution
We can take 1 ball from Bag1 and 2 from Bag2
Probability of 2 black and 1 red
From Bag1 either we get the red or black ball From Bag2 either we get both ball black or one red and one black. (Incase, if Bag1 got a black ball)
1st Possibility
Bag1: 4/9 (Red Ball) Bag2:7/10 (1st Black Ball taken out) -> 6/9 (2nd Black Ball)
2nd Possibility
Bag1: 5/9 (Black Ball) Bag2: 7/10 (1st Black Ball) -> 3/9 (2nd Red Ball)
3rd Possibility
Bag1: 5/9 (Black Ball) Bag2: 3/10 (1st Red Ball ) -> 7/9 (2nd Black Ball)
Multiplying and combining all possibility Possibility#1 + Possibility#2 + Possibility#3 = 7/15