Computer Science Canada Random numbers with no repeat |
Author: | bmass [ Sun Dec 10, 2006 4:10 pm ] |
Post subject: | Random numbers with no repeat |
Hey there, I need to randomly generate 16 numbers from 0 - 15, but they must all be different. Essentially I need to generate the numbers from 0 - 15 in a random order. I also need to do it multiple times. If anyone could help me with this it would be greatly appreciated. Thanks. |
Author: | Tony [ Sun Dec 10, 2006 4:15 pm ] |
Post subject: | |
use an array to keep the numbers not yet picked, then randomly pick a position in the array and take that number out. Repeat until your array size is 0. |