throwing the dice N times, if one of the dices show 1 you automatically lose, the only way you can win is to get at least a 6 without a 1. Dices that doesnt contains 6 loses.
example
[1, 6, 5] = lose
[6, 5, 3] = win
[5, 2, 3] = lose
I tried something like this
public static boolean conditions(int[] array) {
for (int i = 0; i < array.length; i++) {
if (array[i] != 6) {
return false;
}
if (array[i] == 1) {
return false;
}
}
return true;
}
public static int[] generate(int n) {
int[] result = new int[n];
for (int i = 0; i < result.length; i++) {
result[i] = (int) (Math.random() * 6) + 1;
}
return result;
}
public static void main(String[] args) {
double value = 0;
for (int i = 0; i < 100; i++) {
int[] pole = generate(3);
if (conditions(array)) {
value++;
}
}
System.out.println(value);
}
}
the result should look like this
first is the amount of dices and second is the percentage of this working
1= 16,72%
2= 25,00%
3= 28,23%
4= 28,48%
5= 27,08%
6= 24,81%
7= 22,07%
8= 19,35%
9= 16,78%
10= 14,40%
11= 12,29%
12= 10,46%
13= 8,87%
14 7,44%
15= 6,26%
16= 5,25%
17= 4,41%
18= 3,68%
19= 3,09%
20= 2,57%
thank you
would appreciate every help from guys and would love to learn more would appreciate every help from guys and would love to learn more would appreciate every help from guys and would love to learn more would appreciate every help from guys and would love to learn morewould appreciate every help from guys and would love to learn morewould appreciate every help from guys and would love to learn morewould appreciate every help
Aucun commentaire:
Enregistrer un commentaire