You are viewing a single comment's thread. Return to all comments →
java
public class Solution{
public static void main(String[] args) { char[] X = {'r','r','r','r','b','b','b'}; char[] Y = {'r','r','r','r','r','b','b','b','b'}; char[] Z = {'r','r','r','r','b','b','b','b'}; int denom = X.length*Y.length*Z.length; int reds=0; int count =0; for(char x : X){ if(x=='r') reds++; for(char y : Y){ if(y=='r') reds++; for(char z : Z){ if(z=='r') reds++; if(reds==2) { count++; } if(z=='r') reds--; } if(y=='r') reds--; } reds=0; } for (int i = 2; i < Math.sqrt(denom); i++) { if (denom % i == 0 && count % i == 0) { denom = denom / i; count = count / i; i--; } } System.out.println(count +"/"+denom); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Basic Probability Puzzles #3
You are viewing a single comment's thread. Return to all comments →
java
public class Solution{
}