When programming board or role-playing games, many novice programmers experience troubles in converting random values to specific dice points. The goal of this task is to give a practice in simulation of dice rolling by the values coming from a random numbers generator.
Suppose, we have generator which gives random values in range from
0 (inclusive) to
1 (not inclusive) -
this could be encountered in languages like Basic, Java, Matlab etc.
We want to convert these values with floating point to one of six integer numbers: from
6. This could be
achieved by the following steps:
6and so result would be floating point value in range from
flooror converting to
int) - the value will become one of
5with equal probability.
6let us simply add
1to the result.
Now you'll be given several numbers in the range
[0 .. 1) (be sure, they are provided by random number generator) -
and you are to convert them to dice points by applying the algorithm above.
Input data will contain the amount of values to convert in the first line.
Other lines will contain one value each, in form like
Answer should contain numbers from
6 for each of input values, produced by the discussed algorithm.
6 0.59558786964 0.861037873663 0.385597702116 0.246237673331 0.808033385314 0.0544673665427 answer: 4 6 3 2 5 1