Created
September 7, 2018 17:06
-
-
Save Anaminus/5f979fda086ead1f81ad0cc4e929dfd7 to your computer and use it in GitHub Desktop.
Correct 1-index Fisher–Yates shuffle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for i = #a, 2, -1 do | |
| local j = math.random(1, i) | |
| a[i], a[j] = a[j], a[i] | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment