-
-
Save jpdicosola/0f5791fad6591409f748 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_deck(deck) | |
deck.each_with_index do |card, index| | |
deck[index] = deck[Random.rand(51)] | |
end | |
deck | |
end | |
suits = ['S', 'H', 'D', 'C'] | |
numbers = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] | |
deck = [] | |
suits.each do |suit| | |
numbers.each do |number| | |
deck << "#{suit}#{number}" | |
end | |
end | |
shuffle_deck deck | |
puts deck.join(", ") | |
puts "Shuffled #{deck.count} cards." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment