Решение на Четвърта задача от Владимир Алексиев

Обратно към всички решения

Към профила на Владимир Алексиев

Резултати

  • 2 точки от тестове
  • 0 бонус точки
  • 2 точки общо
  • 18 успешни тест(а)
  • 39 неуспешни тест(а)

Код

class Array
def consecutive?
self.map(&:to_i).sort.each_cons(2).all? { |x,y| y == x.next }
end
end
class Card
attr_reader :rank, :suit
ALL_RANKS = (2..10).to_a + [:jack, :queen, :king, :ace]
BELOTE_RANKS = (7..9).to_a + [:jack, :queen, :king, 10, :ace]
SIXTY_SIX_RANKS = [9, :jack, :queen, :king, 10, :ace]
SUITS = [:clubs, :diamonds, :hearts, :spades]
def initialize(rank, suit)
raise ArgumentError.new('invalid rank') unless ALL_RANKS.include? rank
raise ArgumentError.new('invalid suit') unless SUITS.include? suit
@rank, @suit = rank, suit
end
def to_s
"#{@rank.to_s.capitalize} of #{@suit.to_s.capitalize}"
end
def <=>(other)
other_array = [SUITS.index(other.suit), ALL_RANKS.index(other.rank)]
self_array = [SUITS.index(@suit), ALL_RANKS.index(@rank)]
other_array <=> self_array
end
def to_i
ALL_RANKS.index(@rank)
end
end
class Hand
def initialize(cards)
@cards = cards
end
def size
@cards.size
end
private
def king_queen_pair?(suit = false, match_suit = false)
suits = if suit == false then [] else Array(suit) end
do_match = ->(card) {
match_suit ? suits.include?(card.suit) : !suits.include?(card.suit)
}
ranks = [:king, :queen]
match = @cards.select { |card| ranks.include?(card.rank) }.group_by(&:rank)
match[:king].any? do |king|
match[:queen].any? do |queen|
queen.suit == king.suit && do_match.call(queen)
end
end
end
def carre?(rank)
of_rank = @cards.select { |card| card.rank == rank }
return false unless of_rank.size == 4
return false unless of_rank.map(&:suit).uniq.size == 4
true
end
def sequence(length)
@cards.sort.group_by(&:suit).any? do |suit, cards|
false and break if cards.size < length
cards.each_cons(length).any? do |set|
set.consecutive?
end
end
end
end
class WarHand < Hand
def play_card
@cards.pop
end
def allow_face_up?
@cards.size <= 3
end
end
class BeloteHand < Hand
def highest_of_suit(suit)
@cards.sort.group_by(&:suit)[suit].first
end
def belote?
king_queen_pair?
end
def tierce?
sequence(3)
end
def quarte?
sequence(4)
end
def quint?
sequence(5)
end
def carre_of_aces?
carre?(:ace)
end
def carre_of_jacks?
carre?(:jack)
end
def carre_of_nines?
carre?(9)
end
end
class SixtySixHand < Hand
def twenty?(trump_suit)
king_queen_pair?(trump_suit)
end
def forty?(trump_suit)
king_queen_pair?(trump_suit, true)
end
end
class Deck
include Enumerable
alias_method :top_card, :first
def initialize(cards = nil)
@cards = (cards || generate_all_cards)
end
def each(&block)
@cards.map do |card|
yield card
end
end
def deal(number, class_constant = nil)
class_constant ||= Hand
class_constant.send(:new, @cards.shift(number))
end
def size
@cards.size
end
def shuffle
# shuffle! is not working - dunno why ;(
@cards = @cards.shuffle
end
def sort
@cards.sort
end
def to_s
@cards.map(&:to_s).join("\n")
end
def draw_top_card
@cards.shift
end
def draw_bottom_card
@cards.pop
end
def bottom_card
@cards[-1]
end
private
def generate_all_cards
Card::ALL_RANKS.product(Card::SUITS).map { |card| Card.new(*card) }.shuffle
end
def generate_belote_cards
Card::BELOTE_RANKS.product(Card::SUITS)
.map { |card| Card.new(*card) }.shuffle
end
def generate_sixty_six_cards
Card::SIXTY_SIX_RANKS.product(Card::SUITS)
.map { |card| Card.new(*card) }.shuffle
end
end
class WarDeck < Deck
def deal
super(26, WarHand)
end
end
class BeloteDeck < Deck
def initialize
super(generate_belote_cards)
end
def deal
super(8, BeloteHand)
end
end
class SixtySixDeck < Deck
def initialize
super(generate_sixty_six_cards)
end
def deal
super(6, SixtySixHand)
end
end

Лог от изпълнението

..F.F...........FFFFFFF.FF.FFFFFFFFFFFFFFFFFFFFFFF.FF.FFF

Failures:

  1) Card #== compares two cards by their rank and suit
     Failure/Error: expect(Card.new(4, :spades)).to eq Card.new(4, :spades)
       
       expected: #<Card:0x007f112c9f8208 @rank=4, @suit=:spades>
            got: #<Card:0x007f112c9f8280 @rank=4, @suit=:spades>
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,2 @@
       -#<Card:0x007f112c9f8208 @rank=4, @suit=:spades>
       +#<Card:0x007f112c9f8280 @rank=4, @suit=:spades>
     # /tmp/d20151112-27349-e576ru/spec.rb:131:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  2) WarDeck behaves like a deck fills the deck if no initialize parameters are given
     Failure/Error: expect(deck.to_a).to match_array all_available_cards
       expected collection contained:  [#<Card:0x007f112d841990 @rank=:ace, @suit=:spades>, #<Card:0x007f112d8419e0 @rank=:king, @suit=:spades>, #<Card:0x007f112d841a58 @rank=:queen, @suit=:spades>, #<Card:0x007f112d841aa8 @rank=:jack, @suit=:spades>, #<Card:0x007f112d841b20 @rank=10, @suit=:spades>, #<Card:0x007f112d841b70 @rank=9, @suit=:spades>, #<Card:0x007f112d841bc0 @rank=8, @suit=:spades>, #<Card:0x007f112d841c10 @rank=7, @suit=:spades>, #<Card:0x007f112d841c60 @rank=6, @suit=:spades>, #<Card:0x007f112d841cb0 @rank=5, @suit=:spades>, #<Card:0x007f112d841d00 @rank=4, @suit=:spades>, #<Card:0x007f112d841d50 @rank=3, @suit=:spades>, #<Card:0x007f112d841dc8 @rank=2, @suit=:spades>, #<Card:0x007f112d841e18 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d841e68 @rank=:king, @suit=:hearts>, #<Card:0x007f112d841eb8 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d841f30 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d841f80 @rank=10, @suit=:hearts>, #<Card:0x007f112d841fd0 @rank=9, @suit=:hearts>, #<Card:0x007f112d842048 @rank=8, @suit=:hearts>, #<Card:0x007f112d842098 @rank=7, @suit=:hearts>, #<Card:0x007f112d842110 @rank=6, @suit=:hearts>, #<Card:0x007f112d842160 @rank=5, @suit=:hearts>, #<Card:0x007f112d8421b0 @rank=4, @suit=:hearts>, #<Card:0x007f112d842200 @rank=3, @suit=:hearts>, #<Card:0x007f112d842250 @rank=2, @suit=:hearts>, #<Card:0x007f112d8422a0 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d8422f0 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d842340 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d842390 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d842408 @rank=10, @suit=:diamonds>, #<Card:0x007f112d842458 @rank=9, @suit=:diamonds>, #<Card:0x007f112d8424f8 @rank=8, @suit=:diamonds>, #<Card:0x007f112d842548 @rank=7, @suit=:diamonds>, #<Card:0x007f112d842598 @rank=6, @suit=:diamonds>, #<Card:0x007f112d8425e8 @rank=5, @suit=:diamonds>, #<Card:0x007f112d842638 @rank=4, @suit=:diamonds>, #<Card:0x007f112d842688 @rank=3, @suit=:diamonds>, #<Card:0x007f112d8426d8 @rank=2, @suit=:diamonds>, #<Card:0x007f112d842728 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d842778 @rank=:king, @suit=:clubs>, #<Card:0x007f112d8427c8 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d842818 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d842868 @rank=10, @suit=:clubs>, #<Card:0x007f112d8428b8 @rank=9, @suit=:clubs>, #<Card:0x007f112d842908 @rank=8, @suit=:clubs>, #<Card:0x007f112d842958 @rank=7, @suit=:clubs>, #<Card:0x007f112d8429a8 @rank=6, @suit=:clubs>, #<Card:0x007f112d8429f8 @rank=5, @suit=:clubs>, #<Card:0x007f112d842a48 @rank=4, @suit=:clubs>, #<Card:0x007f112d842a98 @rank=3, @suit=:clubs>, #<Card:0x007f112d842ae8 @rank=2, @suit=:clubs>]
       actual collection contained:    [#<Card:0x007f112d8435d8 @rank=:ace, @suit=:spades>, #<Card:0x007f112d843740 @rank=:king, @suit=:spades>, #<Card:0x007f112d843880 @rank=:queen, @suit=:spades>, #<Card:0x007f112d8439c0 @rank=:jack, @suit=:spades>, #<Card:0x007f112d843b00 @rank=10, @suit=:spades>, #<Card:0x007f112d843c40 @rank=9, @suit=:spades>, #<Card:0x007f112d843d80 @rank=8, @suit=:spades>, #<Card:0x007f112d843ee8 @rank=7, @suit=:spades>, #<Card:0x007f112d7c9be8 @rank=6, @suit=:spades>, #<Card:0x007f112d7c8040 @rank=5, @suit=:spades>, #<Card:0x007f112d7c81a8 @rank=4, @suit=:spades>, #<Card:0x007f112d7c8388 @rank=3, @suit=:spades>, #<Card:0x007f112d7c84f0 @rank=2, @suit=:spades>, #<Card:0x007f112d843650 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d843790 @rank=:king, @suit=:hearts>, #<Card:0x007f112d8438d0 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d843a10 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d843b50 @rank=10, @suit=:hearts>, #<Card:0x007f112d843c90 @rank=9, @suit=:hearts>, #<Card:0x007f112d843dd0 @rank=8, @suit=:hearts>, #<Card:0x007f112d843f38 @rank=7, @suit=:hearts>, #<Card:0x007f112d7c9ff8 @rank=6, @suit=:hearts>, #<Card:0x007f112d7c8090 @rank=5, @suit=:hearts>, #<Card:0x007f112d7c8220 @rank=4, @suit=:hearts>, #<Card:0x007f112d7c83d8 @rank=3, @suit=:hearts>, #<Card:0x007f112d7c8568 @rank=2, @suit=:hearts>, #<Card:0x007f112d8436a0 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d8437e0 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d843920 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d843a60 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d843ba0 @rank=10, @suit=:diamonds>, #<Card:0x007f112d843ce0 @rank=9, @suit=:diamonds>, #<Card:0x007f112d843e20 @rank=8, @suit=:diamonds>, #<Card:0x007f112d843f88 @rank=7, @suit=:diamonds>, #<Card:0x007f112d7c9030 @rank=6, @suit=:diamonds>, #<Card:0x007f112d7c8108 @rank=5, @suit=:diamonds>, #<Card:0x007f112d7c8270 @rank=4, @suit=:diamonds>, #<Card:0x007f112d7c8450 @rank=3, @suit=:diamonds>, #<Card:0x007f112d7c85b8 @rank=2, @suit=:diamonds>, #<Card:0x007f112d8436f0 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d843830 @rank=:king, @suit=:clubs>, #<Card:0x007f112d843970 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d843ab0 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d843bf0 @rank=10, @suit=:clubs>, #<Card:0x007f112d843d30 @rank=9, @suit=:clubs>, #<Card:0x007f112d843e70 @rank=8, @suit=:clubs>, #<Card:0x007f112d7cb920 @rank=7, @suit=:clubs>, #<Card:0x007f112d7c8298 @rank=6, @suit=:clubs>, #<Card:0x007f112d7c8158 @rank=5, @suit=:clubs>, #<Card:0x007f112d7c8310 @rank=4, @suit=:clubs>, #<Card:0x007f112d7c84a0 @rank=3, @suit=:clubs>, #<Card:0x007f112d7c8608 @rank=2, @suit=:clubs>]
       the missing elements were:      [#<Card:0x007f112d841990 @rank=:ace, @suit=:spades>, #<Card:0x007f112d8419e0 @rank=:king, @suit=:spades>, #<Card:0x007f112d841a58 @rank=:queen, @suit=:spades>, #<Card:0x007f112d841aa8 @rank=:jack, @suit=:spades>, #<Card:0x007f112d841b20 @rank=10, @suit=:spades>, #<Card:0x007f112d841b70 @rank=9, @suit=:spades>, #<Card:0x007f112d841bc0 @rank=8, @suit=:spades>, #<Card:0x007f112d841c10 @rank=7, @suit=:spades>, #<Card:0x007f112d841c60 @rank=6, @suit=:spades>, #<Card:0x007f112d841cb0 @rank=5, @suit=:spades>, #<Card:0x007f112d841d00 @rank=4, @suit=:spades>, #<Card:0x007f112d841d50 @rank=3, @suit=:spades>, #<Card:0x007f112d841dc8 @rank=2, @suit=:spades>, #<Card:0x007f112d841e18 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d841e68 @rank=:king, @suit=:hearts>, #<Card:0x007f112d841eb8 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d841f30 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d841f80 @rank=10, @suit=:hearts>, #<Card:0x007f112d841fd0 @rank=9, @suit=:hearts>, #<Card:0x007f112d842048 @rank=8, @suit=:hearts>, #<Card:0x007f112d842098 @rank=7, @suit=:hearts>, #<Card:0x007f112d842110 @rank=6, @suit=:hearts>, #<Card:0x007f112d842160 @rank=5, @suit=:hearts>, #<Card:0x007f112d8421b0 @rank=4, @suit=:hearts>, #<Card:0x007f112d842200 @rank=3, @suit=:hearts>, #<Card:0x007f112d842250 @rank=2, @suit=:hearts>, #<Card:0x007f112d8422a0 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d8422f0 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d842340 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d842390 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d842408 @rank=10, @suit=:diamonds>, #<Card:0x007f112d842458 @rank=9, @suit=:diamonds>, #<Card:0x007f112d8424f8 @rank=8, @suit=:diamonds>, #<Card:0x007f112d842548 @rank=7, @suit=:diamonds>, #<Card:0x007f112d842598 @rank=6, @suit=:diamonds>, #<Card:0x007f112d8425e8 @rank=5, @suit=:diamonds>, #<Card:0x007f112d842638 @rank=4, @suit=:diamonds>, #<Card:0x007f112d842688 @rank=3, @suit=:diamonds>, #<Card:0x007f112d8426d8 @rank=2, @suit=:diamonds>, #<Card:0x007f112d842728 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d842778 @rank=:king, @suit=:clubs>, #<Card:0x007f112d8427c8 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d842818 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d842868 @rank=10, @suit=:clubs>, #<Card:0x007f112d8428b8 @rank=9, @suit=:clubs>, #<Card:0x007f112d842908 @rank=8, @suit=:clubs>, #<Card:0x007f112d842958 @rank=7, @suit=:clubs>, #<Card:0x007f112d8429a8 @rank=6, @suit=:clubs>, #<Card:0x007f112d8429f8 @rank=5, @suit=:clubs>, #<Card:0x007f112d842a48 @rank=4, @suit=:clubs>, #<Card:0x007f112d842a98 @rank=3, @suit=:clubs>, #<Card:0x007f112d842ae8 @rank=2, @suit=:clubs>]
       the extra elements were:        [#<Card:0x007f112d8435d8 @rank=:ace, @suit=:spades>, #<Card:0x007f112d843740 @rank=:king, @suit=:spades>, #<Card:0x007f112d843880 @rank=:queen, @suit=:spades>, #<Card:0x007f112d8439c0 @rank=:jack, @suit=:spades>, #<Card:0x007f112d843b00 @rank=10, @suit=:spades>, #<Card:0x007f112d843c40 @rank=9, @suit=:spades>, #<Card:0x007f112d843d80 @rank=8, @suit=:spades>, #<Card:0x007f112d843ee8 @rank=7, @suit=:spades>, #<Card:0x007f112d7c9be8 @rank=6, @suit=:spades>, #<Card:0x007f112d7c8040 @rank=5, @suit=:spades>, #<Card:0x007f112d7c81a8 @rank=4, @suit=:spades>, #<Card:0x007f112d7c8388 @rank=3, @suit=:spades>, #<Card:0x007f112d7c84f0 @rank=2, @suit=:spades>, #<Card:0x007f112d843650 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d843790 @rank=:king, @suit=:hearts>, #<Card:0x007f112d8438d0 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d843a10 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d843b50 @rank=10, @suit=:hearts>, #<Card:0x007f112d843c90 @rank=9, @suit=:hearts>, #<Card:0x007f112d843dd0 @rank=8, @suit=:hearts>, #<Card:0x007f112d843f38 @rank=7, @suit=:hearts>, #<Card:0x007f112d7c9ff8 @rank=6, @suit=:hearts>, #<Card:0x007f112d7c8090 @rank=5, @suit=:hearts>, #<Card:0x007f112d7c8220 @rank=4, @suit=:hearts>, #<Card:0x007f112d7c83d8 @rank=3, @suit=:hearts>, #<Card:0x007f112d7c8568 @rank=2, @suit=:hearts>, #<Card:0x007f112d8436a0 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d8437e0 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d843920 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d843a60 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d843ba0 @rank=10, @suit=:diamonds>, #<Card:0x007f112d843ce0 @rank=9, @suit=:diamonds>, #<Card:0x007f112d843e20 @rank=8, @suit=:diamonds>, #<Card:0x007f112d843f88 @rank=7, @suit=:diamonds>, #<Card:0x007f112d7c9030 @rank=6, @suit=:diamonds>, #<Card:0x007f112d7c8108 @rank=5, @suit=:diamonds>, #<Card:0x007f112d7c8270 @rank=4, @suit=:diamonds>, #<Card:0x007f112d7c8450 @rank=3, @suit=:diamonds>, #<Card:0x007f112d7c85b8 @rank=2, @suit=:diamonds>, #<Card:0x007f112d8436f0 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d843830 @rank=:king, @suit=:clubs>, #<Card:0x007f112d843970 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d843ab0 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d843bf0 @rank=10, @suit=:clubs>, #<Card:0x007f112d843d30 @rank=9, @suit=:clubs>, #<Card:0x007f112d843e70 @rank=8, @suit=:clubs>, #<Card:0x007f112d7cb920 @rank=7, @suit=:clubs>, #<Card:0x007f112d7c8298 @rank=6, @suit=:clubs>, #<Card:0x007f112d7c8158 @rank=5, @suit=:clubs>, #<Card:0x007f112d7c8310 @rank=4, @suit=:clubs>, #<Card:0x007f112d7c84a0 @rank=3, @suit=:clubs>, #<Card:0x007f112d7c8608 @rank=2, @suit=:clubs>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:140
     # /tmp/d20151112-27349-e576ru/spec.rb:18:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  3) BeloteDeck behaves like a deck implements Enumerable
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:191
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:10:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  4) BeloteDeck behaves like a deck fills the deck if no initialize parameters are given
     Failure/Error: expect(deck.to_a).to match_array all_available_cards
       expected collection contained:  [#<Card:0x007f112d7317d0 @rank=:ace, @suit=:spades>, #<Card:0x007f112d731870 @rank=:king, @suit=:spades>, #<Card:0x007f112d7318c0 @rank=:queen, @suit=:spades>, #<Card:0x007f112d731910 @rank=:jack, @suit=:spades>, #<Card:0x007f112d731820 @rank=10, @suit=:spades>, #<Card:0x007f112d731960 @rank=9, @suit=:spades>, #<Card:0x007f112d7319d8 @rank=8, @suit=:spades>, #<Card:0x007f112d731aa0 @rank=7, @suit=:spades>, #<Card:0x007f112d731b18 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d731cd0 @rank=:king, @suit=:hearts>, #<Card:0x007f112d731d70 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d731e10 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d731c58 @rank=10, @suit=:hearts>, #<Card:0x007f112d731e88 @rank=9, @suit=:hearts>, #<Card:0x007f112d731f28 @rank=8, @suit=:hearts>, #<Card:0x007f112d731fc8 @rank=7, @suit=:hearts>, #<Card:0x007f112d732068 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d732220 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d7322e8 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d732338 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d7320b8 @rank=10, @suit=:diamonds>, #<Card:0x007f112d7323d8 @rank=9, @suit=:diamonds>, #<Card:0x007f112d7324a0 @rank=8, @suit=:diamonds>, #<Card:0x007f112d732540 @rank=7, @suit=:diamonds>, #<Card:0x007f112d732590 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d7327c0 @rank=:king, @suit=:clubs>, #<Card:0x007f112d732810 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d732928 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d7326f8 @rank=10, @suit=:clubs>, #<Card:0x007f112d732978 @rank=9, @suit=:clubs>, #<Card:0x007f112d7329f0 @rank=8, @suit=:clubs>, #<Card:0x007f112d732a90 @rank=7, @suit=:clubs>]
       actual collection contained:    [#<Card:0x007f112d7337b0 @rank=:ace, @suit=:spades>, #<Card:0x007f112d733c60 @rank=:king, @suit=:spades>, #<Card:0x007f112d733e18 @rank=:queen, @suit=:spades>, #<Card:0x007f112d733fa8 @rank=:jack, @suit=:spades>, #<Card:0x007f112d733aa8 @rank=10, @suit=:spades>, #<Card:0x007f112d73c040 @rank=9, @suit=:spades>, #<Card:0x007f112d73c1d0 @rank=8, @suit=:spades>, #<Card:0x007f112d73c310 @rank=7, @suit=:spades>, #<Card:0x007f112d733800 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d733cd8 @rank=:king, @suit=:hearts>, #<Card:0x007f112d733e68 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d73d9b8 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d733b20 @rank=10, @suit=:hearts>, #<Card:0x007f112d73c0b8 @rank=9, @suit=:hearts>, #<Card:0x007f112d73c220 @rank=8, @suit=:hearts>, #<Card:0x007f112d73c360 @rank=7, @suit=:hearts>, #<Card:0x007f112d7338a0 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d733d28 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d733eb8 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d73d210 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d733b98 @rank=10, @suit=:diamonds>, #<Card:0x007f112d73c130 @rank=9, @suit=:diamonds>, #<Card:0x007f112d73c270 @rank=8, @suit=:diamonds>, #<Card:0x007f112d73c3b0 @rank=7, @suit=:diamonds>, #<Card:0x007f112d733968 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d733da0 @rank=:king, @suit=:clubs>, #<Card:0x007f112d733f30 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d73ca18 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d733be8 @rank=10, @suit=:clubs>, #<Card:0x007f112d73c180 @rank=9, @suit=:clubs>, #<Card:0x007f112d73c2c0 @rank=8, @suit=:clubs>, #<Card:0x007f112d73c400 @rank=7, @suit=:clubs>]
       the missing elements were:      [#<Card:0x007f112d7317d0 @rank=:ace, @suit=:spades>, #<Card:0x007f112d731870 @rank=:king, @suit=:spades>, #<Card:0x007f112d7318c0 @rank=:queen, @suit=:spades>, #<Card:0x007f112d731910 @rank=:jack, @suit=:spades>, #<Card:0x007f112d731820 @rank=10, @suit=:spades>, #<Card:0x007f112d731960 @rank=9, @suit=:spades>, #<Card:0x007f112d7319d8 @rank=8, @suit=:spades>, #<Card:0x007f112d731aa0 @rank=7, @suit=:spades>, #<Card:0x007f112d731b18 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d731cd0 @rank=:king, @suit=:hearts>, #<Card:0x007f112d731d70 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d731e10 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d731c58 @rank=10, @suit=:hearts>, #<Card:0x007f112d731e88 @rank=9, @suit=:hearts>, #<Card:0x007f112d731f28 @rank=8, @suit=:hearts>, #<Card:0x007f112d731fc8 @rank=7, @suit=:hearts>, #<Card:0x007f112d732068 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d732220 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d7322e8 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d732338 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d7320b8 @rank=10, @suit=:diamonds>, #<Card:0x007f112d7323d8 @rank=9, @suit=:diamonds>, #<Card:0x007f112d7324a0 @rank=8, @suit=:diamonds>, #<Card:0x007f112d732540 @rank=7, @suit=:diamonds>, #<Card:0x007f112d732590 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d7327c0 @rank=:king, @suit=:clubs>, #<Card:0x007f112d732810 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d732928 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d7326f8 @rank=10, @suit=:clubs>, #<Card:0x007f112d732978 @rank=9, @suit=:clubs>, #<Card:0x007f112d7329f0 @rank=8, @suit=:clubs>, #<Card:0x007f112d732a90 @rank=7, @suit=:clubs>]
       the extra elements were:        [#<Card:0x007f112d7337b0 @rank=:ace, @suit=:spades>, #<Card:0x007f112d733c60 @rank=:king, @suit=:spades>, #<Card:0x007f112d733e18 @rank=:queen, @suit=:spades>, #<Card:0x007f112d733fa8 @rank=:jack, @suit=:spades>, #<Card:0x007f112d733aa8 @rank=10, @suit=:spades>, #<Card:0x007f112d73c040 @rank=9, @suit=:spades>, #<Card:0x007f112d73c1d0 @rank=8, @suit=:spades>, #<Card:0x007f112d73c310 @rank=7, @suit=:spades>, #<Card:0x007f112d733800 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d733cd8 @rank=:king, @suit=:hearts>, #<Card:0x007f112d733e68 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d73d9b8 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d733b20 @rank=10, @suit=:hearts>, #<Card:0x007f112d73c0b8 @rank=9, @suit=:hearts>, #<Card:0x007f112d73c220 @rank=8, @suit=:hearts>, #<Card:0x007f112d73c360 @rank=7, @suit=:hearts>, #<Card:0x007f112d7338a0 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d733d28 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d733eb8 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d73d210 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d733b98 @rank=10, @suit=:diamonds>, #<Card:0x007f112d73c130 @rank=9, @suit=:diamonds>, #<Card:0x007f112d73c270 @rank=8, @suit=:diamonds>, #<Card:0x007f112d73c3b0 @rank=7, @suit=:diamonds>, #<Card:0x007f112d733968 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d733da0 @rank=:king, @suit=:clubs>, #<Card:0x007f112d733f30 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d73ca18 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d733be8 @rank=10, @suit=:clubs>, #<Card:0x007f112d73c180 @rank=9, @suit=:clubs>, #<Card:0x007f112d73c2c0 @rank=8, @suit=:clubs>, #<Card:0x007f112d73c400 @rank=7, @suit=:clubs>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:191
     # /tmp/d20151112-27349-e576ru/spec.rb:18:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  5) BeloteDeck behaves like a deck #size returns the size of the deck
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:191
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:23:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  6) BeloteDeck behaves like a deck #draw_top_card pops the top-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:191
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:29:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  7) BeloteDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:191
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:36:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  8) BeloteDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:191
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:43:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  9) BeloteDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:191
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:50:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  10) BeloteDeck behaves like a deck #to_s returns the names of the cards, each on its own line
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:191
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:68:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  11) BeloteDeck #sort sorts the cards in the defined order
     Failure/Error: deck = BeloteDeck.new(cards)
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:204:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:204:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  12) BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:221:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:221:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  13) BeloteDeck hand #belote? returns true if there is a king and a queen of the same suit
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:240:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:240:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  14) BeloteDeck hand #belote? returns false when there is no king and queen of the same suit
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:255:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:255:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  15) BeloteDeck hand #tierce? with tierce returns true for cards with names
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:273:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:273:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  16) BeloteDeck hand #tierce? with tierce returns true for cards with numbers
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:288:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:288:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  17) BeloteDeck hand #tierce? without tierce does not confuse cards with different suits
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:305:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:305:in `block (5 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  18) BeloteDeck hand #quarte? detects four cards with increasing ranks
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:323:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:323:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  19) BeloteDeck hand #quarte? does not return true if there is no quarte
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:338:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:338:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  20) BeloteDeck hand #quint? detects five cards with increasing ranks
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:355:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:355:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  21) BeloteDeck hand #quint? does not return true if there is no quint
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:370:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:370:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  22) BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-e576ru/spec.rb:386
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:75:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:75:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  23) BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns false when there is no carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-e576ru/spec.rb:386
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:90:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:90:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  24) BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns true when there is a carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-e576ru/spec.rb:390
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:75:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:75:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  25) BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns false when there is no carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-e576ru/spec.rb:390
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:90:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:90:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  26) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-e576ru/spec.rb:394
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:75:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:75:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  27) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns false when there is no carre
     Failure/Error: hand = BeloteDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-e576ru/spec.rb:394
     # /tmp/d20151112-27349-e576ru/solution.rb:216:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:90:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:90:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  28) SixtySixDeck behaves like a deck implements Enumerable
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:400
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:10:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  29) SixtySixDeck behaves like a deck fills the deck if no initialize parameters are given
     Failure/Error: expect(deck.to_a).to match_array all_available_cards
       expected collection contained:  [#<Card:0x007f112d21e1d0 @rank=:ace, @suit=:spades>, #<Card:0x007f112d21e2c0 @rank=:king, @suit=:spades>, #<Card:0x007f112d21e388 @rank=:queen, @suit=:spades>, #<Card:0x007f112d21e428 @rank=:jack, @suit=:spades>, #<Card:0x007f112d21e248 @rank=10, @suit=:spades>, #<Card:0x007f112d21e5b8 @rank=9, @suit=:spades>, #<Card:0x007f112d21e608 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d21e770 @rank=:king, @suit=:hearts>, #<Card:0x007f112d21e7c0 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d21e810 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d21e680 @rank=10, @suit=:hearts>, #<Card:0x007f112d21e860 @rank=9, @suit=:hearts>, #<Card:0x007f112d21e8b0 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d21e978 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d21e9f0 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d21ea90 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d21e928 @rank=10, @suit=:diamonds>, #<Card:0x007f112d21eb08 @rank=9, @suit=:diamonds>, #<Card:0x007f112d21eba8 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d21ec98 @rank=:king, @suit=:clubs>, #<Card:0x007f112d21ed10 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d21ed88 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d21ec20 @rank=10, @suit=:clubs>, #<Card:0x007f112d21edd8 @rank=9, @suit=:clubs>]
       actual collection contained:    [#<Card:0x007f112d21f6e8 @rank=:ace, @suit=:spades>, #<Card:0x007f112d21faa8 @rank=:king, @suit=:spades>, #<Card:0x007f112d21fd78 @rank=:queen, @suit=:spades>, #<Card:0x007f112d2325b8 @rank=:jack, @suit=:spades>, #<Card:0x007f112d21f878 @rank=10, @suit=:spades>, #<Card:0x007f112d230150 @rank=9, @suit=:spades>, #<Card:0x007f112d21f760 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d21fbc0 @rank=:king, @suit=:hearts>, #<Card:0x007f112d21fe68 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d230038 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d21f968 @rank=10, @suit=:hearts>, #<Card:0x007f112d2301a0 @rank=9, @suit=:hearts>, #<Card:0x007f112d21f7b0 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d21fc10 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d21ff58 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d230088 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d21f9e0 @rank=10, @suit=:diamonds>, #<Card:0x007f112d2301f0 @rank=9, @suit=:diamonds>, #<Card:0x007f112d21f800 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d21fcb0 @rank=:king, @suit=:clubs>, #<Card:0x007f112d233260 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d230100 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d21fa30 @rank=10, @suit=:clubs>, #<Card:0x007f112d2302b8 @rank=9, @suit=:clubs>]
       the missing elements were:      [#<Card:0x007f112d21e1d0 @rank=:ace, @suit=:spades>, #<Card:0x007f112d21e2c0 @rank=:king, @suit=:spades>, #<Card:0x007f112d21e388 @rank=:queen, @suit=:spades>, #<Card:0x007f112d21e428 @rank=:jack, @suit=:spades>, #<Card:0x007f112d21e248 @rank=10, @suit=:spades>, #<Card:0x007f112d21e5b8 @rank=9, @suit=:spades>, #<Card:0x007f112d21e608 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d21e770 @rank=:king, @suit=:hearts>, #<Card:0x007f112d21e7c0 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d21e810 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d21e680 @rank=10, @suit=:hearts>, #<Card:0x007f112d21e860 @rank=9, @suit=:hearts>, #<Card:0x007f112d21e8b0 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d21e978 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d21e9f0 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d21ea90 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d21e928 @rank=10, @suit=:diamonds>, #<Card:0x007f112d21eb08 @rank=9, @suit=:diamonds>, #<Card:0x007f112d21eba8 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d21ec98 @rank=:king, @suit=:clubs>, #<Card:0x007f112d21ed10 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d21ed88 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d21ec20 @rank=10, @suit=:clubs>, #<Card:0x007f112d21edd8 @rank=9, @suit=:clubs>]
       the extra elements were:        [#<Card:0x007f112d21f6e8 @rank=:ace, @suit=:spades>, #<Card:0x007f112d21faa8 @rank=:king, @suit=:spades>, #<Card:0x007f112d21fd78 @rank=:queen, @suit=:spades>, #<Card:0x007f112d2325b8 @rank=:jack, @suit=:spades>, #<Card:0x007f112d21f878 @rank=10, @suit=:spades>, #<Card:0x007f112d230150 @rank=9, @suit=:spades>, #<Card:0x007f112d21f760 @rank=:ace, @suit=:hearts>, #<Card:0x007f112d21fbc0 @rank=:king, @suit=:hearts>, #<Card:0x007f112d21fe68 @rank=:queen, @suit=:hearts>, #<Card:0x007f112d230038 @rank=:jack, @suit=:hearts>, #<Card:0x007f112d21f968 @rank=10, @suit=:hearts>, #<Card:0x007f112d2301a0 @rank=9, @suit=:hearts>, #<Card:0x007f112d21f7b0 @rank=:ace, @suit=:diamonds>, #<Card:0x007f112d21fc10 @rank=:king, @suit=:diamonds>, #<Card:0x007f112d21ff58 @rank=:queen, @suit=:diamonds>, #<Card:0x007f112d230088 @rank=:jack, @suit=:diamonds>, #<Card:0x007f112d21f9e0 @rank=10, @suit=:diamonds>, #<Card:0x007f112d2301f0 @rank=9, @suit=:diamonds>, #<Card:0x007f112d21f800 @rank=:ace, @suit=:clubs>, #<Card:0x007f112d21fcb0 @rank=:king, @suit=:clubs>, #<Card:0x007f112d233260 @rank=:queen, @suit=:clubs>, #<Card:0x007f112d230100 @rank=:jack, @suit=:clubs>, #<Card:0x007f112d21fa30 @rank=10, @suit=:clubs>, #<Card:0x007f112d2302b8 @rank=9, @suit=:clubs>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:400
     # /tmp/d20151112-27349-e576ru/spec.rb:18:in `block (2 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  30) SixtySixDeck behaves like a deck #size returns the size of the deck
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:400
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:23:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  31) SixtySixDeck behaves like a deck #draw_top_card pops the top-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:400
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:29:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  32) SixtySixDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:400
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:36:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  33) SixtySixDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:400
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:43:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  34) SixtySixDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:400
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:50:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  35) SixtySixDeck behaves like a deck #to_s returns the names of the cards, each on its own line
     Failure/Error: let(:small_deck) { deck_class.new([ace_of_spades, nine_of_clubs]) }
     ArgumentError:
       wrong number of arguments (1 for 0)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-e576ru/spec.rb:400
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:6:in `block (2 levels) in <top (required)>'
     # /tmp/d20151112-27349-e576ru/spec.rb:68:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  36) SixtySixDeck #sort sorts the cards in the defined order
     Failure/Error: deck = SixtySixDeck.new(cards)
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:413:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:413:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  37) SixtySixDeck hand #twenty? returns true for king and queen not of the trump suit
     Failure/Error: hand = SixtySixDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:430:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:430:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  38) SixtySixDeck hand #twenty? returns false for king and queen of the trump suit
     Failure/Error: hand = SixtySixDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:443:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:443:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

  39) SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit
     Failure/Error: hand = SixtySixDeck.new([
     ArgumentError:
       wrong number of arguments (1 for 0)
     # /tmp/d20151112-27349-e576ru/solution.rb:227:in `initialize'
     # /tmp/d20151112-27349-e576ru/spec.rb:456:in `new'
     # /tmp/d20151112-27349-e576ru/spec.rb:456:in `block (4 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>'
     # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.05212 seconds
57 examples, 39 failures

Failed examples:

rspec /tmp/d20151112-27349-e576ru/spec.rb:130 # Card #== compares two cards by their rank and suit
rspec /tmp/d20151112-27349-e576ru/spec.rb:14 # WarDeck behaves like a deck fills the deck if no initialize parameters are given
rspec /tmp/d20151112-27349-e576ru/spec.rb:8 # BeloteDeck behaves like a deck implements Enumerable
rspec /tmp/d20151112-27349-e576ru/spec.rb:14 # BeloteDeck behaves like a deck fills the deck if no initialize parameters are given
rspec /tmp/d20151112-27349-e576ru/spec.rb:22 # BeloteDeck behaves like a deck #size returns the size of the deck
rspec /tmp/d20151112-27349-e576ru/spec.rb:28 # BeloteDeck behaves like a deck #draw_top_card pops the top-most card
rspec /tmp/d20151112-27349-e576ru/spec.rb:35 # BeloteDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-e576ru/spec.rb:42 # BeloteDeck behaves like a deck #top peeks at the top-most card
rspec /tmp/d20151112-27349-e576ru/spec.rb:49 # BeloteDeck behaves like a deck #bottom peeks at the bottom-most card
rspec /tmp/d20151112-27349-e576ru/spec.rb:67 # BeloteDeck behaves like a deck #to_s returns the names of the cards, each on its own line
rspec /tmp/d20151112-27349-e576ru/spec.rb:196 # BeloteDeck #sort sorts the cards in the defined order
rspec /tmp/d20151112-27349-e576ru/spec.rb:220 # BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit
rspec /tmp/d20151112-27349-e576ru/spec.rb:239 # BeloteDeck hand #belote? returns true if there is a king and a queen of the same suit
rspec /tmp/d20151112-27349-e576ru/spec.rb:254 # BeloteDeck hand #belote? returns false when there is no king and queen of the same suit
rspec /tmp/d20151112-27349-e576ru/spec.rb:272 # BeloteDeck hand #tierce? with tierce returns true for cards with names
rspec /tmp/d20151112-27349-e576ru/spec.rb:287 # BeloteDeck hand #tierce? with tierce returns true for cards with numbers
rspec /tmp/d20151112-27349-e576ru/spec.rb:304 # BeloteDeck hand #tierce? without tierce does not confuse cards with different suits
rspec /tmp/d20151112-27349-e576ru/spec.rb:322 # BeloteDeck hand #quarte? detects four cards with increasing ranks
rspec /tmp/d20151112-27349-e576ru/spec.rb:337 # BeloteDeck hand #quarte? does not return true if there is no quarte
rspec /tmp/d20151112-27349-e576ru/spec.rb:354 # BeloteDeck hand #quint? detects five cards with increasing ranks
rspec /tmp/d20151112-27349-e576ru/spec.rb:369 # BeloteDeck hand #quint? does not return true if there is no quint
rspec /tmp/d20151112-27349-e576ru/spec.rb:74 # BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-e576ru/spec.rb:89 # BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns false when there is no carre
rspec /tmp/d20151112-27349-e576ru/spec.rb:74 # BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-e576ru/spec.rb:89 # BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns false when there is no carre
rspec /tmp/d20151112-27349-e576ru/spec.rb:74 # BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre
rspec /tmp/d20151112-27349-e576ru/spec.rb:89 # BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns false when there is no carre
rspec /tmp/d20151112-27349-e576ru/spec.rb:8 # SixtySixDeck behaves like a deck implements Enumerable
rspec /tmp/d20151112-27349-e576ru/spec.rb:14 # SixtySixDeck behaves like a deck fills the deck if no initialize parameters are given
rspec /tmp/d20151112-27349-e576ru/spec.rb:22 # SixtySixDeck behaves like a deck #size returns the size of the deck
rspec /tmp/d20151112-27349-e576ru/spec.rb:28 # SixtySixDeck behaves like a deck #draw_top_card pops the top-most card
rspec /tmp/d20151112-27349-e576ru/spec.rb:35 # SixtySixDeck behaves like a deck #draw_bottom_card pops the bottom-most card
rspec /tmp/d20151112-27349-e576ru/spec.rb:42 # SixtySixDeck behaves like a deck #top peeks at the top-most card
rspec /tmp/d20151112-27349-e576ru/spec.rb:49 # SixtySixDeck behaves like a deck #bottom peeks at the bottom-most card
rspec /tmp/d20151112-27349-e576ru/spec.rb:67 # SixtySixDeck behaves like a deck #to_s returns the names of the cards, each on its own line
rspec /tmp/d20151112-27349-e576ru/spec.rb:405 # SixtySixDeck #sort sorts the cards in the defined order
rspec /tmp/d20151112-27349-e576ru/spec.rb:429 # SixtySixDeck hand #twenty? returns true for king and queen not of the trump suit
rspec /tmp/d20151112-27349-e576ru/spec.rb:442 # SixtySixDeck hand #twenty? returns false for king and queen of the trump suit
rspec /tmp/d20151112-27349-e576ru/spec.rb:455 # SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit

История (2 версии и 1 коментар)

Владимир обнови решението на 11.11.2015 13:50 (преди около 9 години)

+require 'awesome_print'
+
+class Array
+
+ def consecutive?
+ self.map(&:to_i).sort.each_cons(2).all? { |x,y| y == x.next }
+ end
+end
+
+class Card
+
+ attr_reader :rank, :suit
+
+ ALL_RANKS = (2..10).to_a + [:jack, :queen, :king, :ace]
+ BELOTE_RANKS = (7..9).to_a + [:jack, :queen, :king, 10, :ace]
+ SIXTY_SIX_RANKS = [9, :jack, :queen, :king, 10, :ace]
+
+ SUITS = [:clubs, :diamonds, :hearts, :spades]
+
+ def initialize(rank, suit)
+ raise ArgumentError.new('invalid rank') unless ALL_RANKS.include? rank
+ raise ArgumentError.new('invalid suit') unless SUITS.include? suit
+ @rank, @suit = rank, suit
+ end
+
+ def to_s
+ "#{@rank.to_s.capitalize} of #{@suit.to_s.capitalize}"
+ end
+
+ def <=>(other)
+ other_array = [SUITS.index(other.suit), ALL_RANKS.index(other.rank)]
+ self_array = [SUITS.index(@suit), ALL_RANKS.index(@rank)]
+ other_array <=> self_array
+ end
+
+ def to_i
+ ALL_RANKS.index(@rank)
+ end
+end
+
+class Hand
+
+ def initialize(cards)
+ @cards = cards
+ end
+
+ def size
+ @cards.size
+ end
+
+ private
+
+ def king_queen_pair?(suit = false, match_suit = false)
+ suits = if suit == false then [] else Array(suit) end
+ do_match = ->(card) {
+ match_suit ? suits.include?(card.suit) : !suits.include?(card.suit)
+ }
+ ranks = [:king, :queen]
+ match = @cards.select { |card| ranks.include?(card.rank) }.group_by(&:rank)
+ match[:king].any? do |king|
+ match[:queen].any? do |queen|
+ queen.suit == king.suit && do_match.call(queen)
+ end
+ end
+ end
+
+ def carre?(rank)
+ of_rank = @cards.select { |card| card.rank == rank }
+ return false unless of_rank.size == 4
+ return false unless of_rank.map(&:suit).uniq.size == 4
+ true
+ end
+
+ def sequence(length)
+ @cards.sort.group_by(&:suit).any? do |suit, cards|
+ false and break if cards.size < length
+ cards.each_cons(length).any? do |set|
+ set.consecutive?
+ end
+ end
+ end
+end
+
+class WarHand < Hand
+
+ def play_card
+ @cards.pop
+ end
+
+ def allow_face_up?
+ @cards.size <= 3
+ end
+end
+
+class BeloteHand < Hand
+
+ def highest_of_suit(suit)
+ @cards.sort.group_by(&:suit)[suit].first
+ end
+
+ def belote?
+ king_queen_pair?
+ end
+
+ def tierce?
+ sequence(3)
+ end
+
+ def quarte?
+ sequence(4)
+ end
+
+ def quint?
+ sequence(5)
+ end
+
+ def carre_of_aces?
+ carre?(:ace)
+ end
+
+ def carre_of_jacks?
+ carre?(:jack)
+ end
+
+ def carre_of_nines?
+ carre?(9)
+ end
+end
+
+class SixtySixHand < Hand
+
+ def twenty?(trump_suit)
+ king_queen_pair?(trump_suit)
+ end
+
+ def forty?(trump_suit)
+ king_queen_pair?(trump_suit, true)
+ end
+end
+
+class Deck
+
+ include Enumerable
+
+ alias_method :top_card, :first
+
+ def initialize(cards = nil)
+ @cards = (cards || generate_all_cards)
+ end
+
+ def each(&block)
+ @cards.map do |card|
+ yield card
+ end
+ end
+
+ def deal(number, class_constant = nil)
+ class_constant ||= Hand
+ class_constant.send(:new, @cards.shift(number))
+ end
+
+ def size
+ @cards.size
+ end
+
+ def shuffle
+ # shuffle! is not working - dunno why ;(
+ @cards = @cards.shuffle
+ end
+
+ def sort
+ @cards.sort
+ end
+
+ def to_s
+ @cards.map(&:to_s).join("\n")
+ end
+
+ def draw_top_card
+ @cards.shift
+ end
+
+ def draw_bottom_card
+ @cards.pop
+ end
+
+ def bottom_card
+ @cards[-1]
+ end
+
+ private
+
+ def generate_all_cards
+ Card::ALL_RANKS.product(Card::SUITS).map { |card| Card.new(*card) }.shuffle
+ end
+
+ def generate_belote_cards
+ Card::BELOTE_RANKS.product(Card::SUITS)
+ .map { |card| Card.new(*card) }.shuffle
+ end
+
+ def generate_sixty_six_cards
+ Card::SIXTY_SIX_RANKS.product(Card::SUITS)
+ .map { |card| Card.new(*card) }.shuffle
+ end
+
+end
+
+class WarDeck < Deck
+
+ def deal
+ super(26, WarHand)
+ end
+end
+
+class BeloteDeck < Deck
+
+ def initialize
+ super(generate_belote_cards)
+ end
+
+ def deal
+ super(8, BeloteHand)
+ end
+end
+
+class SixtySixDeck < Deck
+
+ def initialize
+ super(generate_sixty_six_cards)
+ end
+
+
+ def deal
+ super(6, SixtySixHand)
+ end
+end

Владимир обнови решението на 11.11.2015 13:50 (преди около 9 години)

-require 'awesome_print'
-
class Array
def consecutive?
self.map(&:to_i).sort.each_cons(2).all? { |x,y| y == x.next }
end
end
class Card
attr_reader :rank, :suit
ALL_RANKS = (2..10).to_a + [:jack, :queen, :king, :ace]
BELOTE_RANKS = (7..9).to_a + [:jack, :queen, :king, 10, :ace]
SIXTY_SIX_RANKS = [9, :jack, :queen, :king, 10, :ace]
SUITS = [:clubs, :diamonds, :hearts, :spades]
def initialize(rank, suit)
raise ArgumentError.new('invalid rank') unless ALL_RANKS.include? rank
raise ArgumentError.new('invalid suit') unless SUITS.include? suit
@rank, @suit = rank, suit
end
def to_s
"#{@rank.to_s.capitalize} of #{@suit.to_s.capitalize}"
end
def <=>(other)
other_array = [SUITS.index(other.suit), ALL_RANKS.index(other.rank)]
self_array = [SUITS.index(@suit), ALL_RANKS.index(@rank)]
other_array <=> self_array
end
def to_i
ALL_RANKS.index(@rank)
end
end
class Hand
def initialize(cards)
@cards = cards
end
def size
@cards.size
end
private
def king_queen_pair?(suit = false, match_suit = false)
suits = if suit == false then [] else Array(suit) end
do_match = ->(card) {
match_suit ? suits.include?(card.suit) : !suits.include?(card.suit)
}
ranks = [:king, :queen]
match = @cards.select { |card| ranks.include?(card.rank) }.group_by(&:rank)
match[:king].any? do |king|
match[:queen].any? do |queen|
queen.suit == king.suit && do_match.call(queen)
end
end
end
def carre?(rank)
of_rank = @cards.select { |card| card.rank == rank }
return false unless of_rank.size == 4
return false unless of_rank.map(&:suit).uniq.size == 4
true
end
def sequence(length)
@cards.sort.group_by(&:suit).any? do |suit, cards|
false and break if cards.size < length
cards.each_cons(length).any? do |set|
set.consecutive?
end
end
end
end
class WarHand < Hand
def play_card
@cards.pop
end
def allow_face_up?
@cards.size <= 3
end
end
class BeloteHand < Hand
def highest_of_suit(suit)
@cards.sort.group_by(&:suit)[suit].first
end
def belote?
king_queen_pair?
end
def tierce?
sequence(3)
end
def quarte?
sequence(4)
end
def quint?
sequence(5)
end
def carre_of_aces?
carre?(:ace)
end
def carre_of_jacks?
carre?(:jack)
end
def carre_of_nines?
carre?(9)
end
end
class SixtySixHand < Hand
def twenty?(trump_suit)
king_queen_pair?(trump_suit)
end
def forty?(trump_suit)
king_queen_pair?(trump_suit, true)
end
end
class Deck
include Enumerable
alias_method :top_card, :first
def initialize(cards = nil)
@cards = (cards || generate_all_cards)
end
def each(&block)
@cards.map do |card|
yield card
end
end
def deal(number, class_constant = nil)
class_constant ||= Hand
class_constant.send(:new, @cards.shift(number))
end
def size
@cards.size
end
def shuffle
# shuffle! is not working - dunno why ;(
@cards = @cards.shuffle
end
def sort
@cards.sort
end
def to_s
@cards.map(&:to_s).join("\n")
end
def draw_top_card
@cards.shift
end
def draw_bottom_card
@cards.pop
end
def bottom_card
@cards[-1]
end
private
def generate_all_cards
Card::ALL_RANKS.product(Card::SUITS).map { |card| Card.new(*card) }.shuffle
end
def generate_belote_cards
Card::BELOTE_RANKS.product(Card::SUITS)
.map { |card| Card.new(*card) }.shuffle
end
def generate_sixty_six_cards
Card::SIXTY_SIX_RANKS.product(Card::SUITS)
.map { |card| Card.new(*card) }.shuffle
end
end
class WarDeck < Deck
def deal
super(26, WarHand)
end
end
class BeloteDeck < Deck
def initialize
super(generate_belote_cards)
end
def deal
super(8, BeloteHand)
end
end
class SixtySixDeck < Deck
def initialize
super(generate_sixty_six_cards)
end
def deal
super(6, SixtySixHand)
end
end

Monkey patch-а на Array е на ръба да го накажем с отнемане на точка.

Имаш проблеми със спазването на конвенциите на места, направи справка с ръководството за стил.

Прегледай и решенията на колеги и нашето примерно решение за алтернативни идеи.