RosettaCodeData/Task/Knuth-shuffle/Crystal/knuth-shuffle.crystal
2020-02-17 23:21:07 -08: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