Unrepeated random numbers

Miscellaneous Forums/General Discussion/Unrepeated random numbers

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Classic case of overengineering!

He didn't ask how to shuffle, he asked how to get 52 non-repeating random numbers!
(Which we can assume are the numbers 1 thru 52, making our task easier.)

Dim Deck(52)

SeedRnd MilliSecs()

For Loop = 1 to 52
   Repeat
      A = Rand(0, 51)
   Until Deck(A) = 0
   Deck(A) = Loop
Next


You will need to reset all elements of Deck() to 0 if you want to generate a new set of non-repeating numbers.