java - query for Math.random to generate only a certain amount of each number needed -


I'm curious if anyone tells the way to use math.random By generating random numbers 0 and 3, but when it produces two 0 or two 1, then they deny the possibility of creating them?

This is for a game assignment for college and what I have left is set to produce two of each number with only one. If someone knows how useful it will be (even if it is using someone other than math.random .

The language is Java.

< / Div>

So, you basically want to keep track of numbers, okay?

A Possible Solution Use an array whose length is the legal limit of your random number, where each cell counts the number of related numbers. Then, for each draw , You check the contents of the respective cell in the array, see if you have reached the limit, if you have done, then repeat and repeat.

Note: The language is unknown, but the solution can normally be implemented in any language which provides a random () function.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -