Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- int t_throws = 10;
- int s_sides = 6;
- int x_multiple = 6;
- int[] diceCurrentValues = new int[t_throws];
- for (int i = 0; i < diceCurrentValues.length; i++) diceCurrentValues[i] = 1;
- int combinations = 0;
- int matches = 0;
- for (; ; ) {
- // calculate the sum of the current combination
- int sum = 0;
- for (int diceValue : diceCurrentValues) sum += diceValue;
- combinations++;
- if (sum % x_multiple == 0) matches++;
- System.out.println("status: " + matches + "/" + combinations + "=" + (matches * 100 / (double) combinations) + "%");
- // create the next dice combination
- int dicePointer = 0;
- boolean incremented = false;
- while (!incremented) {
- if (dicePointer == diceCurrentValues.length) return;
- if (diceCurrentValues[dicePointer] == s_sides) {
- diceCurrentValues[dicePointer] = 1;
- dicePointer++;
- } else {
- diceCurrentValues[dicePointer]++;
- incremented = true;
- }
- }
- }
- }
- int t_throws = 10;
- int s_sides = 6;
- int x_multiple = 4;
Add Comment
Please, Sign In to add comment