java - to map a range of numbers in an array to uniform random 1 to 100 -
I have 5 dice and I roll each of them once: The result is the meaning [] = {1, 1, 1, 1, 1}
This dice [] array is a function Has an input which means
int random {// do some work with dice values {1, 1, 1, 1, 1} (as input from user ) // Return the same random number from 1 to 100 Rule: Only the source of randomness is the value in the dice array. How do I make each of the numbers from 1 to 100 so that the resulting value is almost the same generation?
Please help
You are 1, 6, 6 ^ 2, 6 ^ 3, 6 ^ 4 can increase numbers on the dice. Then add them and take the last two digits of the result (i.e., finally one% 100).
Edit (Thanks pjs) As the last step, add 1 so that you get an answer between 1 and 100, not 0 And between 99
Comments
Post a Comment