Skip to content

Instantly share code, notes, and snippets.

@MarkBorcherding
Created May 18, 2010 01:13
Show Gist options
  • Save MarkBorcherding/404476 to your computer and use it in GitHub Desktop.
Save MarkBorcherding/404476 to your computer and use it in GitHub Desktop.
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
@MarkBorcherding
Copy link
Author

made it a Knuth Shuffle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment