Created
May 18, 2010 01:13
-
-
Save MarkBorcherding/404476 to your computer and use it in GitHub Desktop.
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
Array.send :define_method, :swap do |a,b| | |
temp = deck[a] | |
self[a] = self[b] | |
self[b] = temp | |
end | |
Array.send :define_method, :shuffle do |i| | |
length = self.length | |
0.upto(length-1) do | |
swapKeys = [i,rand(length)] | |
self.swap(swapKeys[0],swapKeys[1]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
made it a Knuth Shuffle.