Skip to content

Instantly share code, notes, and snippets.

@saterus
Created January 19, 2012 01:48
Show Gist options
  • Save saterus/1637080 to your computer and use it in GitHub Desktop.
Save saterus/1637080 to your computer and use it in GitHub Desktop.
Ruby Shuffle
# Shuffles all the unused cards in the shoe. Uses the
# Fisher-Yates shuffling algorithm.
# Returns nil.
def shuffle!
(@contents.size-1).downto(2) { |n|
m = rand(n+1)
@contents[n], @contents[m] = @contents[m], @contents[n]
}
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment