rolling a seven when at least one die is a four?

75 Views Asked by At

I have been working on some stuff like this and I am fairly confused, I wrote some code to see how it works when simulated and I am further from an answer.

public static void main(String[] args) {

double ROLLS = 10000000.0;
int count = 0;
Dice a = new Dice(6);
Dice b = new Dice(6);

for (int i = 0; i < ROLLS; i++) {
  a.roll();
  b.roll();
  if (a.getDots() == 4 || b.getDots() == 4)
    if (a.getDots() + b.getDots() == 7)
      count++;
}
System.out.println(count/ROLLS + "\n1/6 = .1666 \n 1/12 = .083333");
}

Im getting about 1/12 every time I run it and I am confused as to how this is possible. Thank you!

edit: sorry, programmers mind :P

Basically, if I were to roll two dies, at the same time, and ensure that AT LEAST ONE of the dies are a four, what is the probability that the sum of the two dies will be 7?

1

There are 1 best solutions below

0
On BEST ANSWER

How many have at least one 4? how many don't? If they don't there are 5 options for each digit. So there are 25 that don't. we know there are 36 total, so 36-25 do, which is 11.

only (3,4) and (4,3) add up 7 and have a 4. So the answer is $\frac{2}{11}$