grrr wrote:
> So suppose you have a deck of cards, that might have some number of 
> cards.
> 
> First the cards are shuffled, in effect placed in random order.
> 
> Then the deck is split, ie. some number of cards are lifted from the top
> of the deck and placed under the remaining cards.
> 
> How would one implement this? I was thinking of using an array, but how 
> to
> shuffle the deck, and how to split the deck?
> 
> grrr

class Array
  def shuffle
    self.sort_by{rand}
  end

  def cut(index)
    (self-self[0..index]).push(*self[0..index])
  end
end

-- 
Posted via http://www.ruby-forum.com/.