Created
May 6, 2016 02:09
-
-
Save shtakai/58183b6a0764b44001b22e47af0dfb4e to your computer and use it in GitHub Desktop.
This file contains 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
def shuffle(l) | |
return l[0] if l.size == 1 | |
i = l.index(l.sample) | |
h = l[i] | |
l.delete_at(i) | |
return [h, shuffle(l)].flatten | |
end | |
array = [1,2,3,4,5,6] | |
p shuffle(array) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO: