James Gray
3/16/2006 9:04:00 PM
On Mar 16, 2006, at 2:53 PM, grrr wrote:
> how to shuffle the deck
>> cards = %w{A 2 3 4 5 6 7 8 9 T J Q K A}
=> ["A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K",
"A"]
>> cards = cards.sort_by { rand } # shuffle
=> ["6", "T", "Q", "5", "A", "J", "2", "7", "4", "8", "A", "9", "K",
"3"]
> and how to split the deck?
>> cards = cards.values_at(3..-1, 0..2) # cut
=> ["5", "A", "J", "2", "7", "4", "8", "A", "9", "K", "3", "6", "T",
"Q"]
Hope that gives you some new ideas.
James Edward Gray II