Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
random numbers
#7
Followup with code for most efficient shuffle known to mathematicians!:

Code: (Select All)
TopN = 52
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); Chr$(9);
Next
Print
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: 1 Guest(s)