java - Generating unique random numbers and check duplicates -


this question has answer here:

i generate 3*6 digits, can form array of 3rows*6cols. don't want duplicated found in column. can anywhere, in same row, in each column, there shouldn't duplicate of same number. there algorithm generating ?

fill matrix column-wise , use set keep track of numbers have used in current column. can use do-while statement each cell, in pseudo-code:

for each column {   used = new set   each cell in column {     {       num = generate random number     } while (num in used)     add num used     add num current cell   } } 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -