Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fisher Yates Shuffle for cards or any number of items
#1
As discussed in Ranking Poker Hands:
Code: (Select All)
TopN = 52
ReDim n(1 To TopN) 'repeatable for ref
For i = 1 To TopN
    n(i) = i
Next
For i = TopN To 2 Step -1 ' Fisher Yates Shuffle of N Items
    Swap n(i), n(Int(Rnd * (i) + 1))
Next
For i = 1 To TopN
    Print "  "; i; "-"; n(i); Chr$(9);
Next
Print

At maximum you need only swap n-1 items!
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
Fisher Yates Shuffle for cards or any number of items - by bplus - 06-19-2023, 11:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Weighted Random number about a Center bplus 3 951 01-25-2023, 06:45 PM
Last Post: bplus
  Drop down (& up) number pad OldMoses 1 774 09-24-2022, 03:37 PM
Last Post: mnrvovrfc

Forum Jump:


Users browsing this thread: 1 Guest(s)