2014년 12월 27일 토요일

random number generator


How might i generate a random number with a certain number of digits and not get a repetition.

--
I assume you "random number" means "random integer".  

to get one with a specified number of digits, use the random integer block (math drawer).

To not get repetitions, keep a list CHOSEN of the numbers already chosen.  To get a new random number

pick a random integer, call it R
check if R is in the CHOSEN list
 if R is not, add R to the CHOSEN list and use R and your next number
else if R in the CHOSEN list, pick a new random integer for R and repeat the process

--
Very good...thx


--


댓글 없음:

댓글 쓰기