RosettaCodeData/Task/Knuth-shuffle/Crystal/knuth-shuffle.crystal
2023-07-01 13:44:08 -04:00

9 lines
152 B
Text

def knuthShuffle(items : Array)
i = items.size-1
while i > 1
j = Random.rand(0..i)
items.swap(i, j)
i -= 1
end
end