Guest User

Untitled

a guest
Jan 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. public static void main(String[] args) {
  2. int t_throws = 10;
  3. int s_sides = 6;
  4. int x_multiple = 6;
  5. int[] diceCurrentValues = new int[t_throws];
  6. for (int i = 0; i < diceCurrentValues.length; i++) diceCurrentValues[i] = 1;
  7.  
  8. int combinations = 0;
  9. int matches = 0;
  10. for (; ; ) {
  11. // calculate the sum of the current combination
  12. int sum = 0;
  13. for (int diceValue : diceCurrentValues) sum += diceValue;
  14.  
  15. combinations++;
  16. if (sum % x_multiple == 0) matches++;
  17. System.out.println("status: " + matches + "/" + combinations + "=" + (matches * 100 / (double) combinations) + "%");
  18.  
  19. // create the next dice combination
  20. int dicePointer = 0;
  21. boolean incremented = false;
  22. while (!incremented) {
  23. if (dicePointer == diceCurrentValues.length) return;
  24. if (diceCurrentValues[dicePointer] == s_sides) {
  25. diceCurrentValues[dicePointer] = 1;
  26. dicePointer++;
  27. } else {
  28. diceCurrentValues[dicePointer]++;
  29. incremented = true;
  30. }
  31. }
  32. }
  33. }
  34.  
  35. int t_throws = 10;
  36. int s_sides = 6;
  37. int x_multiple = 4;
Add Comment
Please, Sign In to add comment