Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
random numbers
#8
Here is that code applied to your, @badger specific case:
Code: (Select All)
' Generate a random number between -1 and 71

' 0 to 71 = 72 cards plus 1 for -1 = 73 cards

' without repetition

Randomize Timer ' for new random set nearly every time
TopN = 73
ReDim n(1 To TopN) 'repeatable for ref
For i = 1 To TopN
    n(i) = i
Next

' shuffle
For i = TopN To 2 Step -1 ' Fisher Yates Shuffle of N Items
    Swap n(i), n(Int(Rnd * (i) + 1))
Next

' results of shuffle
For i = 1 To TopN
    Print "  "; i; "-"; n(i) - 2; Chr$(9); ' <<<<< subtract 2 for number -1 to 71
Next
Print

   

Ha! You have 14 sets of 5 unique and non intersecting sets of numbers from 1 Shuffle of deck of 73 cards.
b = b + ...
Reply


Messages In This Thread
random numbers - by badger - 11-06-2024, 11:15 PM
RE: random numbers - by Dav - 11-06-2024, 11:30 PM
RE: random numbers - by badger - 11-06-2024, 11:42 PM
RE: random numbers - by Dav - 11-06-2024, 11:51 PM
RE: random numbers - by Kernelpanic - 11-07-2024, 05:24 PM
RE: random numbers - by bplus - 11-07-2024, 05:52 PM
RE: random numbers - by bplus - 11-07-2024, 07:03 PM
RE: random numbers - by bplus - 11-07-2024, 07:10 PM
RE: random numbers - by DANILIN - 11-08-2024, 02:22 AM



Users browsing this thread: 2 Guest(s)