Решение на Четвърта задача от Пламена Петрова

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

Към профила на Пламена Петрова

Резултати

  • 1 точка от тестове
  • 1 отнета точка
  • 0 точки общо
  • 10 успешни тест(а)
  • 47 неуспешни тест(а)

Код

class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
@rank = rank
@suit = suit
end
def to_s
puts "#{rank.to_s.capitalize} of #{suit.to_s.capitalize}"
end
def ==(other)
@rank == other.rank and @suit == other.suit
end
end
class Deck < Card
include Enumerable
attr_accessor :cards, :ranks
def initialize(*cards_array, ranks)
@cards, @ranks = Array[], ranks
case cards_array.size
when 0
make_array_of_cards(ranks)
else
@cards = cards_array
end
end
def make_array_of_cards(ranks)
suits = [:spades, :hearts, :diamonds, :clubs]
suits.each do |suit|
ranks.size.times do |i|
@cards << Card.new( ranks[i], suit)
end
end
end
def each
current = 1
while current <= @cards.size
yield (@cards[current - 1]).to_s
current = current + 1
end
end
def to_s
@cards.each do |card|
card.to_s
end
end
def size
@cards.size
end
def draw_bottom_card
@cards.pop
end
def draw_top_card
@cards.shift
end
def shuffle
@cards.shuffle!
end
def top_card
@card.at(0)
end
def bottom_card
@card.at(-1)
end
def sort
suits = [:spades, :hearts, :diamonds, :clubs]
@cards.sort! do |x, y|
comp = (suits.index(x.suit) <=> suits.index(y.suit))
comp.zero? ? (ranks.index(y.rank) <=> ranks.index(x.rank)) : comp
end
end
def deal(amount_of_cards, players_deck)
amount_of_cards.times do
players_deck.cards.push(self.draw_top_card)
end
end
end
class WarDeck < Deck
def initialize(*args)
ranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, :jack, :queen, :king, :ace]
super(*args, ranks)
end
def deal
players_deck = WarPlayersDeck.new
super(26, players_deck)
players_deck
end
def sort
super()
end
end
class WarPlayersDeck < Deck
def initialize
@ranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, :jack, :queen, :king, :ace]
@cards = Array[]
end
def play_card
@cards.delete_at((0..(cards.size - 1)).to_a.sample)
end
def allow_face_up?
@cards.size <= 3
end
end
class BeloteDeck < Deck
def initialize(*args)
@ranks = [7, 8, 9, :jack, :queen, :king, 10, :ace]
super(*args, ranks)
end
def deal
players_deck = BelotePlayersDeck.new
super(8, players_deck)
players_deck
end
def sort
super()
end
end
class BelotePlayersDeck < Deck
def initialize
@ranks = [7, 8, 9, :jack, :queen, :king, 10, :ace]
@cards = Array[]
end
def sort
super()
end
def highest_of_suit(suit)
self.sort
(@cards.select {|card| card.suit == suit}).at(0)
end
def has?(suit, rank)
@cards.any? {|card| card.rank == rank && card.suit == suit}
end
def belote?
couples = 0
suits = [:spades, :hearts, :diamonds, :clubs]
suits.each do |suit|
if (has?(suit, :king) && has?(suit, :queen))
couples = couples + 1
end
end
couples > 0
end
def tierce?
tierce, suits = 0, [:spades, :hearts, :diamonds, :clubs]
ranks =[7, 8, 9, :jack, :queen, :king, 10, :ace]
suits.each do |suit|
count_three_in_a_row(ranks, suit)
end
tierce > 0
end
def count_three_in_a_row(ranks, suit)
ranks.each_c(3) do |c|
if (has?(suit, c.at(0))) &&
(has?(suit, c.at(1))) && (has?(suit, c.at(2)))
tierce = tierce + 1
end
end
end
def quarte?
quarte, suits = 0, [:spades, :hearts, :diamonds, :clubs]
ranks = [7, 8, 9, :jack, :queen, :king, 10, :ace]
suits.each do |suit|
count_four_in_a_row(ranks, suit)
end
quarte > 0
end
def count_four_in_a_row(ranks, suit)
ranks.each_c(4) do |c|
if (has?(suit, c.at(0))) && (has?(suit, c.at(1))) &&
(has?(suit, c.at(2))) && (has?(suit, c.at(3)))
quarte = quarte + 1
end
end
end
def quint?
quint, suits = 0, [:spades, :hearts, :diamonds, :clubs]
ranks = [7, 8, 9, :jack, :queen, :king, 10, :ace]
suits.each do |suit|
count_five_in_a_row(ranks, suit)
end
quint > 0
end
def count_five_in_a_row(ranks, suit)
ranks.each_c(5) do |c|
if has?(suit, c.at(0)) && has?(suit, c.at(1)) &&
has?(suit, c.at(2)) && has?(suit, c.at(3)) && has?(suit, c.at(4))
quint = quint + 1
end
end
end
def carre_of_jacks?
carre = 0
suits = [:spades, :hearts, :diamonds, :clubs]
suits.each do |suit|
if (has?(suit, :jack))
carre = carre + 1
end
end
carre == 4
end
def carre_of_nines?
carre = 0
suits = [:spades, :hearts, :diamonds, :clubs]
suits.each do |suit|
if (has?(suit, 9))
carre = carre + 1
end
end
carre == 4
end
def carre_of_aces?
carre = 0
suits = [:spades, :hearts, :diamonds, :clubs]
suits.each do |suit|
if (has?(suit, :ace))
carre = carre + 1
end
end
carre == 4
end
end
class SixtySixDeck < Deck
def initialize(*args)
@ranks = [9, :jack, :queen, :king, 10, :ace]
super(*args, ranks)
end
def deal
players_deck = SixtySixPlayersDeck.new
super(6, players_deck)
players_deck
end
def sort
super()
end
end
class SixtySixPlayersDeck < Deck
def initialize
@ranks = [9, :jack, :queen, :king, 10, :ace]
@cards = Array[]
end
def sort
super()
end
def has?(suit, rank)
@cards.any? {|card| card.rank == rank && card.suit == suit}
end
def twenty?(trump_suit)
couples = 0
suits = [:spades, :hearts, :diamonds, :clubs] - trump_suit
suits.each do |suit|
if (has?(suit, :king) && has?(suit, :queen))
couples = couples + 1
end
end
couples > 0
end
def forty?(trump_suit)
has?(suit, :king) && has?(suit, :queen)
end
end

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

2 of Clubs
3 of Clubs
4 of Clubs
5 of Clubs
6 of Clubs
7 of Clubs
8 of Clubs
9 of Clubs
10 of Clubs
Jack of Clubs
Queen of Clubs
King of Clubs
Ace of Clubs
2 of Diamonds
3 of Diamonds
4 of Diamonds
5 of Diamonds
6 of Diamonds
7 of Diamonds
8 of Diamonds
9 of Diamonds
10 of Diamonds
Jack of Diamonds
Queen of Diamonds
King of Diamonds
Ace of Diamonds
2 of Hearts
3 of Hearts
4 of Hearts
5 of Hearts
6 of Hearts
7 of Hearts
8 of Hearts
9 of Hearts
10 of Hearts
Jack of Hearts
Queen of Hearts
King of Hearts
Ace of Hearts
2 of Spades
3 of Spades
4 of Spades
5 of Spades
6 of Spades
7 of Spades
8 of Spades
9 of Spades
10 of Spades
Jack of Spades
Queen of Spades
King of Spades
Ace of Spades
F..F2 of Spades
3 of Spades
4 of Spades
5 of Spades
6 of Spades
7 of Spades
8 of Spades
9 of Spades
10 of Spades
Jack of Spades
Queen of Spades
King of Spades
Ace of Spades
2 of Hearts
3 of Hearts
4 of Hearts
5 of Hearts
6 of Hearts
7 of Hearts
8 of Hearts
9 of Hearts
10 of Hearts
Jack of Hearts
Queen of Hearts
King of Hearts
Ace of Hearts
2 of Diamonds
3 of Diamonds
4 of Diamonds
5 of Diamonds
6 of Diamonds
7 of Diamonds
8 of Diamonds
9 of Diamonds
10 of Diamonds
Jack of Diamonds
Queen of Diamonds
King of Diamonds
Ace of Diamonds
2 of Clubs
3 of Clubs
4 of Clubs
5 of Clubs
6 of Clubs
7 of Clubs
8 of Clubs
9 of Clubs
10 of Clubs
Jack of Clubs
Queen of Clubs
King of Clubs
Ace of Clubs
FFFFFF.FF...F7 of Spades
8 of Spades
9 of Spades
Jack of Spades
Queen of Spades
King of Spades
10 of Spades
Ace of Spades
7 of Hearts
8 of Hearts
9 of Hearts
Jack of Hearts
Queen of Hearts
King of Hearts
10 of Hearts
Ace of Hearts
7 of Diamonds
8 of Diamonds
9 of Diamonds
Jack of Diamonds
Queen of Diamonds
King of Diamonds
10 of Diamonds
Ace of Diamonds
7 of Clubs
8 of Clubs
9 of Clubs
Jack of Clubs
Queen of Clubs
King of Clubs
10 of Clubs
Ace of Clubs
FFFFFF.FF.FFFFFFFFFFFFFFFFF9 of Spades
Jack of Spades
Queen of Spades
King of Spades
10 of Spades
Ace of Spades
9 of Hearts
Jack of Hearts
Queen of Hearts
King of Hearts
10 of Hearts
Ace of Hearts
9 of Diamonds
Jack of Diamonds
Queen of Diamonds
King of Diamonds
10 of Diamonds
Ace of Diamonds
9 of Clubs
Jack of Clubs
Queen of Clubs
King of Clubs
10 of Clubs
Ace of Clubs
FFFFFF.FF.FFF

Failures:

  1) Card #to_s stringifies and capitalizes the rank and suit
     Failure/Error: expect(all_cards.map(&:to_s)).to eq all_card_names
       
       expected: ["2 of Clubs", "3 of Clubs", "4 of Clubs", "5 of Clubs", "6 of Clubs", "7 of Clubs", "8 of Clubs", "9 of Clubs", "10 of Clubs", "Jack of Clubs", "Queen of Clubs", "King of Clubs", "Ace of Clubs", "2 of Diamonds", "3 of Diamonds", "4 of Diamonds", "5 of Diamonds", "6 of Diamonds", "7 of Diamonds", "8 of Diamonds", "9 of Diamonds", "10 of Diamonds", "Jack of Diamonds", "Queen of Diamonds", "King of Diamonds", "Ace of Diamonds", "2 of Hearts", "3 of Hearts", "4 of Hearts", "5 of Hearts", "6 of Hearts", "7 of Hearts", "8 of Hearts", "9 of Hearts", "10 of Hearts", "Jack of Hearts", "Queen of Hearts", "King of Hearts", "Ace of Hearts", "2 of Spades", "3 of Spades", "4 of Spades", "5 of Spades", "6 of Spades", "7 of Spades", "8 of Spades", "9 of Spades", "10 of Spades", "Jack of Spades", "Queen of Spades", "King of Spades", "Ace of Spades"]
            got: [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
       
       (compared using ==)
       
       Diff:
       @@ -1,53 +1,53 @@
       -["2 of Clubs",
       - "3 of Clubs",
       - "4 of Clubs",
       - "5 of Clubs",
       - "6 of Clubs",
       - "7 of Clubs",
       - "8 of Clubs",
       - "9 of Clubs",
       - "10 of Clubs",
       - "Jack of Clubs",
       - "Queen of Clubs",
       - "King of Clubs",
       - "Ace of Clubs",
       - "2 of Diamonds",
       - "3 of Diamonds",
       - "4 of Diamonds",
       - "5 of Diamonds",
       - "6 of Diamonds",
       - "7 of Diamonds",
       - "8 of Diamonds",
       - "9 of Diamonds",
       - "10 of Diamonds",
       - "Jack of Diamonds",
       - "Queen of Diamonds",
       - "King of Diamonds",
       - "Ace of Diamonds",
       - "2 of Hearts",
       - "3 of Hearts",
       - "4 of Hearts",
       - "5 of Hearts",
       - "6 of Hearts",
       - "7 of Hearts",
       - "8 of Hearts",
       - "9 of Hearts",
       - "10 of Hearts",
       - "Jack of Hearts",
       - "Queen of Hearts",
       - "King of Hearts",
       - "Ace of Hearts",
       - "2 of Spades",
       - "3 of Spades",
       - "4 of Spades",
       - "5 of Spades",
       - "6 of Spades",
       - "7 of Spades",
       - "8 of Spades",
       - "9 of Spades",
       - "10 of Spades",
       - "Jack of Spades",
       - "Queen of Spades",
       - "King of Spades",
       - "Ace of Spades"]
       +[nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil,
       + nil]
     # /tmp/d20151112-27349-1giz2b5/spec.rb:116: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 implements Enumerable
     Failure/Error: expect(small_deck.to_a).to eq [ace_of_spades, nine_of_clubs]
       
       expected: [#<Card:0x007f938d6fe398 @rank=:ace, @suit=:spades>, #<Card:0x007f938d6fe370 @rank=9, @suit=:clubs>]
            got: ["[#<Card:0x007f938d6fe398 @rank=:ace, @suit=:spades>, #<Card:0x007f938d6fe370 @rank=9, @suit=:clubs>]"]
       
       (compared using ==)
       
       Diff:
       @@ -1,3 +1,2 @@
       -[#<Card:0x007f938d6fe398 @rank=:ace, @suit=:spades>,
       - #<Card:0x007f938d6fe370 @rank=9, @suit=:clubs>]
       +["[#<Card:0x007f938d6fe398 @rank=:ace, @suit=:spades>, #<Card:0x007f938d6fe370 @rank=9, @suit=:clubs>]"]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:140
     # /tmp/d20151112-27349-1giz2b5/spec.rb:11: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) 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
     NoMethodError:
       undefined method `rank' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:140
     # /tmp/d20151112-27349-1giz2b5/solution.rb:14:in `=='
     # /tmp/d20151112-27349-1giz2b5/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)>'

  4) WarDeck behaves like a deck #size returns the size of the deck
     Failure/Error: expect(small_deck.size).to eq 2
       
       expected: 2
            got: 1
       
       (compared using ==)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:140
     # /tmp/d20151112-27349-1giz2b5/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)>'

  5) WarDeck behaves like a deck #draw_top_card pops the top-most card
     Failure/Error: expect(small_deck.draw_top_card).to eq ace_of_spades
       
       expected: #<Card:0x007f938d6666d8 @rank=:ace, @suit=:spades>
            got: [#<Card:0x007f938d6666d8 @rank=:ace, @suit=:spades>, #<Card:0x007f938d6666b0 @rank=9, @suit=:clubs>]
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,3 @@
       -#<Card:0x007f938d6666d8 @rank=:ace, @suit=:spades>
       +[#<Card:0x007f938d6666d8 @rank=:ace, @suit=:spades>,
       + #<Card:0x007f938d6666b0 @rank=9, @suit=:clubs>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:140
     # /tmp/d20151112-27349-1giz2b5/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)>'

  6) WarDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: expect(small_deck.draw_bottom_card).to eq nine_of_clubs
       
       expected: #<Card:0x007f938d623360 @rank=9, @suit=:clubs>
            got: [#<Card:0x007f938d6233b0 @rank=:ace, @suit=:spades>, #<Card:0x007f938d623360 @rank=9, @suit=:clubs>]
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,3 @@
       -#<Card:0x007f938d623360 @rank=9, @suit=:clubs>
       +[#<Card:0x007f938d6233b0 @rank=:ace, @suit=:spades>,
       + #<Card:0x007f938d623360 @rank=9, @suit=:clubs>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:140
     # /tmp/d20151112-27349-1giz2b5/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)>'

  7) WarDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: expect(small_deck.top_card).to eq ace_of_spades
     NoMethodError:
       undefined method `at' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:140
     # /tmp/d20151112-27349-1giz2b5/solution.rb:74:in `top_card'
     # /tmp/d20151112-27349-1giz2b5/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)>'

  8) WarDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: expect(small_deck.bottom_card).to eq nine_of_clubs
     NoMethodError:
       undefined method `at' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:140
     # /tmp/d20151112-27349-1giz2b5/solution.rb:78:in `bottom_card'
     # /tmp/d20151112-27349-1giz2b5/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)>'

  9) WarDeck behaves like a deck #to_s returns the names of the cards, each on its own line
     Failure/Error: expect(small_deck.to_s.strip).to eq "Ace of Spades\n9 of Clubs"
     NoMethodError:
       undefined method `strip' for #<Array:0x007f938d5bf928>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:140
     # /tmp/d20151112-27349-1giz2b5/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)>'

  10) WarDeck #sort sorts the cards in the defined order
     Failure/Error: expect(deck.sort.to_a).to eq [jack_of_spades, ten_of_hearts, ace_of_clubs, two_of_clubs]
       
       expected: [#<Card:0x007f938d5b17d8 @rank=:jack, @suit=:spades>, #<Card:0x007f938d5b1698 @rank=10, @suit=:hearts>, #<Card:0x007f938d5b1828 @rank=:ace, @suit=:clubs>, #<Card:0x007f938d5b1788 @rank=2, @suit=:clubs>]
            got: [[#<Card:0x007f938d5b1828 @rank=:ace, @suit=:clubs>, #<Card:0x007f938d5b17d8 @rank=:jack, @suit=:spades>, #<Card:0x007f938d5b1788 @rank=2, @suit=:clubs>, #<Card:0x007f938d5b1698 @rank=10, @suit=:hearts>]]
       
       (compared using ==)
       
       Diff:
       @@ -1,5 +1,5 @@
       -[#<Card:0x007f938d5b17d8 @rank=:jack, @suit=:spades>,
       - #<Card:0x007f938d5b1698 @rank=10, @suit=:hearts>,
       - #<Card:0x007f938d5b1828 @rank=:ace, @suit=:clubs>,
       - #<Card:0x007f938d5b1788 @rank=2, @suit=:clubs>]
       +[[#<Card:0x007f938d5b1828 @rank=:ace, @suit=:clubs>,
       +  #<Card:0x007f938d5b17d8 @rank=:jack, @suit=:spades>,
       +  #<Card:0x007f938d5b1788 @rank=2, @suit=:clubs>,
       +  #<Card:0x007f938d5b1698 @rank=10, @suit=:hearts>]]
     # /tmp/d20151112-27349-1giz2b5/spec.rb:155: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 behaves like a deck implements Enumerable
     Failure/Error: expect(small_deck.to_a).to eq [ace_of_spades, nine_of_clubs]
       
       expected: [#<Card:0x007f938d516dc8 @rank=:ace, @suit=:spades>, #<Card:0x007f938d516d50 @rank=9, @suit=:clubs>]
            got: ["[#<Card:0x007f938d516dc8 @rank=:ace, @suit=:spades>, #<Card:0x007f938d516d50 @rank=9, @suit=:clubs>]"]
       
       (compared using ==)
       
       Diff:
       @@ -1,3 +1,2 @@
       -[#<Card:0x007f938d516dc8 @rank=:ace, @suit=:spades>,
       - #<Card:0x007f938d516d50 @rank=9, @suit=:clubs>]
       +["[#<Card:0x007f938d516dc8 @rank=:ace, @suit=:spades>, #<Card:0x007f938d516d50 @rank=9, @suit=:clubs>]"]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:191
     # /tmp/d20151112-27349-1giz2b5/spec.rb:11: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)>'

  12) 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
     NoMethodError:
       undefined method `rank' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:191
     # /tmp/d20151112-27349-1giz2b5/solution.rb:14:in `=='
     # /tmp/d20151112-27349-1giz2b5/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)>'

  13) BeloteDeck behaves like a deck #size returns the size of the deck
     Failure/Error: expect(small_deck.size).to eq 2
       
       expected: 2
            got: 1
       
       (compared using ==)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:191
     # /tmp/d20151112-27349-1giz2b5/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)>'

  14) BeloteDeck behaves like a deck #draw_top_card pops the top-most card
     Failure/Error: expect(small_deck.draw_top_card).to eq ace_of_spades
       
       expected: #<Card:0x007f938d47fa68 @rank=:ace, @suit=:spades>
            got: [#<Card:0x007f938d47fa68 @rank=:ace, @suit=:spades>, #<Card:0x007f938d47fa18 @rank=9, @suit=:clubs>]
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,3 @@
       -#<Card:0x007f938d47fa68 @rank=:ace, @suit=:spades>
       +[#<Card:0x007f938d47fa68 @rank=:ace, @suit=:spades>,
       + #<Card:0x007f938d47fa18 @rank=9, @suit=:clubs>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:191
     # /tmp/d20151112-27349-1giz2b5/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)>'

  15) BeloteDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: expect(small_deck.draw_bottom_card).to eq nine_of_clubs
       
       expected: #<Card:0x007f938d43e068 @rank=9, @suit=:clubs>
            got: [#<Card:0x007f938d43e090 @rank=:ace, @suit=:spades>, #<Card:0x007f938d43e068 @rank=9, @suit=:clubs>]
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,3 @@
       -#<Card:0x007f938d43e068 @rank=9, @suit=:clubs>
       +[#<Card:0x007f938d43e090 @rank=:ace, @suit=:spades>,
       + #<Card:0x007f938d43e068 @rank=9, @suit=:clubs>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:191
     # /tmp/d20151112-27349-1giz2b5/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)>'

  16) BeloteDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: expect(small_deck.top_card).to eq ace_of_spades
     NoMethodError:
       undefined method `at' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:191
     # /tmp/d20151112-27349-1giz2b5/solution.rb:74:in `top_card'
     # /tmp/d20151112-27349-1giz2b5/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)>'

  17) BeloteDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: expect(small_deck.bottom_card).to eq nine_of_clubs
     NoMethodError:
       undefined method `at' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:191
     # /tmp/d20151112-27349-1giz2b5/solution.rb:78:in `bottom_card'
     # /tmp/d20151112-27349-1giz2b5/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)>'

  18) BeloteDeck behaves like a deck #to_s returns the names of the cards, each on its own line
     Failure/Error: expect(small_deck.to_s.strip).to eq "Ace of Spades\n9 of Clubs"
     NoMethodError:
       undefined method `strip' for #<Array:0x007f938d1e5168>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:191
     # /tmp/d20151112-27349-1giz2b5/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)>'

  19) BeloteDeck #sort sorts the cards in the defined order
     Failure/Error: expect(deck.sort.to_a).to eq [jack_of_spades, ten_of_hearts, ace_of_clubs, seven_of_clubs]
       
       expected: [#<Card:0x007f938d1b4dd8 @rank=:jack, @suit=:spades>, #<Card:0x007f938d1b4ce8 @rank=10, @suit=:hearts>, #<Card:0x007f938d1b4f18 @rank=:ace, @suit=:clubs>, #<Card:0x007f938d1b4db0 @rank=7, @suit=:clubs>]
            got: [[#<Card:0x007f938d1b4f18 @rank=:ace, @suit=:clubs>, #<Card:0x007f938d1b4dd8 @rank=:jack, @suit=:spades>, #<Card:0x007f938d1b4db0 @rank=7, @suit=:clubs>, #<Card:0x007f938d1b4ce8 @rank=10, @suit=:hearts>]]
       
       (compared using ==)
       
       Diff:
       @@ -1,5 +1,5 @@
       -[#<Card:0x007f938d1b4dd8 @rank=:jack, @suit=:spades>,
       - #<Card:0x007f938d1b4ce8 @rank=10, @suit=:hearts>,
       - #<Card:0x007f938d1b4f18 @rank=:ace, @suit=:clubs>,
       - #<Card:0x007f938d1b4db0 @rank=7, @suit=:clubs>]
       +[[#<Card:0x007f938d1b4f18 @rank=:ace, @suit=:clubs>,
       +  #<Card:0x007f938d1b4dd8 @rank=:jack, @suit=:spades>,
       +  #<Card:0x007f938d1b4db0 @rank=7, @suit=:clubs>,
       +  #<Card:0x007f938d1b4ce8 @rank=10, @suit=:hearts>]]
     # /tmp/d20151112-27349-1giz2b5/spec.rb:206: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)>'

  20) BeloteDeck hand #highest_of_suit returns the strongest card of the specified suit
     Failure/Error: expect(hand.highest_of_suit(:clubs)).to eq Card.new(:ace, :clubs)
     NoMethodError:
       undefined method `suit' for #<Array:0x007f938d0824b0>
     # /tmp/d20151112-27349-1giz2b5/solution.rb:84:in `block in sort'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:83:in `sort!'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:83:in `sort'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:153:in `sort'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:157:in `highest_of_suit'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:232: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 #belote? returns true if there is a king and a queen of the same suit
     Failure/Error: expect(hand.belote?).to be true
     NoMethodError:
       undefined method `rank' for #<Array:0x007f938d032730>
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `block in has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `any?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:169:in `block in belote?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:168:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:168:in `belote?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:251: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 #belote? returns false when there is no king and queen of the same suit
     Failure/Error: expect(hand.belote?).to be false
     NoMethodError:
       undefined method `rank' for #<Array:0x007f938d00f2d0>
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `block in has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `any?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:169:in `block in belote?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:168:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:168:in `belote?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:266: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)>'

  23) BeloteDeck hand #tierce? with tierce returns true for cards with names
     Failure/Error: expect(hand.tierce?).to be true
     NoMethodError:
       undefined method `each_c' for [7, 8, 9, :jack, :queen, :king, 10, :ace]:Array
     # /tmp/d20151112-27349-1giz2b5/solution.rb:186:in `count_three_in_a_row'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:180:in `block in tierce?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:179:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:179:in `tierce?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:284: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)>'

  24) BeloteDeck hand #tierce? with tierce returns true for cards with numbers
     Failure/Error: expect(hand.tierce?).to be true
     NoMethodError:
       undefined method `each_c' for [7, 8, 9, :jack, :queen, :king, 10, :ace]:Array
     # /tmp/d20151112-27349-1giz2b5/solution.rb:186:in `count_three_in_a_row'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:180:in `block in tierce?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:179:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:179:in `tierce?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:299: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)>'

  25) BeloteDeck hand #tierce? without tierce does not confuse cards with different suits
     Failure/Error: expect(hand.tierce?).to be false
     NoMethodError:
       undefined method `each_c' for [7, 8, 9, :jack, :queen, :king, 10, :ace]:Array
     # /tmp/d20151112-27349-1giz2b5/solution.rb:186:in `count_three_in_a_row'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:180:in `block in tierce?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:179:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:179:in `tierce?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:316: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)>'

  26) BeloteDeck hand #quarte? detects four cards with increasing ranks
     Failure/Error: expect(hand.quarte?).to be true
     NoMethodError:
       undefined method `each_c' for [7, 8, 9, :jack, :queen, :king, 10, :ace]:Array
     # /tmp/d20151112-27349-1giz2b5/solution.rb:204:in `count_four_in_a_row'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:198:in `block in quarte?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:197:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:197:in `quarte?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:334: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)>'

  27) BeloteDeck hand #quarte? does not return true if there is no quarte
     Failure/Error: expect(hand.quarte?).to be false
     NoMethodError:
       undefined method `each_c' for [7, 8, 9, :jack, :queen, :king, 10, :ace]:Array
     # /tmp/d20151112-27349-1giz2b5/solution.rb:204:in `count_four_in_a_row'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:198:in `block in quarte?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:197:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:197:in `quarte?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:349: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)>'

  28) BeloteDeck hand #quint? detects five cards with increasing ranks
     Failure/Error: expect(hand.quint?).to be true
     NoMethodError:
       undefined method `each_c' for [7, 8, 9, :jack, :queen, :king, 10, :ace]:Array
     # /tmp/d20151112-27349-1giz2b5/solution.rb:222:in `count_five_in_a_row'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:216:in `block in quint?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:215:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:215:in `quint?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:366: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)>'

  29) BeloteDeck hand #quint? does not return true if there is no quint
     Failure/Error: expect(hand.quint?).to be false
     NoMethodError:
       undefined method `each_c' for [7, 8, 9, :jack, :queen, :king, 10, :ace]:Array
     # /tmp/d20151112-27349-1giz2b5/solution.rb:222:in `count_five_in_a_row'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:216:in `block in quint?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:215:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:215:in `quint?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:381: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)>'

  30) BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns true when there is a carre
     Failure/Error: expect(hand.public_send(method)).to be true
     NoMethodError:
       undefined method `rank' for #<Array:0x007f938c8ade10>
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1giz2b5/spec.rb:386
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `block in has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `any?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:234:in `block in carre_of_jacks?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:233:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:233:in `carre_of_jacks?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:86:in `public_send'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:86: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)>'

  31) BeloteDeck hand #carre_of_jacks? behaves like carre-checking method returns false when there is no carre
     Failure/Error: expect(hand.public_send(method)).to be false
     NoMethodError:
       undefined method `rank' for #<Array:0x007f938c8a4388>
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1giz2b5/spec.rb:386
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `block in has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `any?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:234:in `block in carre_of_jacks?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:233:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:233:in `carre_of_jacks?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:101:in `public_send'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:101: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)>'

  32) BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns true when there is a carre
     Failure/Error: expect(hand.public_send(method)).to be true
     NoMethodError:
       undefined method `rank' for #<Array:0x007f938c8a31b8>
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1giz2b5/spec.rb:390
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `block in has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `any?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:245:in `block in carre_of_nines?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:244:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:244:in `carre_of_nines?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:86:in `public_send'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:86: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)>'

  33) BeloteDeck hand #carre_of_nines? behaves like carre-checking method returns false when there is no carre
     Failure/Error: expect(hand.public_send(method)).to be false
     NoMethodError:
       undefined method `rank' for #<Array:0x007f938c89b170>
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1giz2b5/spec.rb:390
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `block in has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `any?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:245:in `block in carre_of_nines?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:244:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:244:in `carre_of_nines?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:101:in `public_send'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:101: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)>'

  34) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns true when there is a carre
     Failure/Error: expect(hand.public_send(method)).to be true
     NoMethodError:
       undefined method `rank' for #<Array:0x007f938c8bb3f8>
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1giz2b5/spec.rb:394
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `block in has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `any?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:256:in `block in carre_of_aces?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:255:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:255:in `carre_of_aces?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:86:in `public_send'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:86: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)>'

  35) BeloteDeck hand #carre_of_aces? behaves like carre-checking method returns false when there is no carre
     Failure/Error: expect(hand.public_send(method)).to be false
     NoMethodError:
       undefined method `rank' for #<Array:0x007f938c8b3d88>
     Shared Example Group: "carre-checking method" called from /tmp/d20151112-27349-1giz2b5/spec.rb:394
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `block in has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `any?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:162:in `has?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:256:in `block in carre_of_aces?'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:255:in `each'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:255:in `carre_of_aces?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:101:in `public_send'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:101: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)>'

  36) SixtySixDeck behaves like a deck implements Enumerable
     Failure/Error: expect(small_deck.to_a).to eq [ace_of_spades, nine_of_clubs]
       
       expected: [#<Card:0x007f938c8a8640 @rank=:ace, @suit=:spades>, #<Card:0x007f938c8a85a0 @rank=9, @suit=:clubs>]
            got: ["[#<Card:0x007f938c8a8640 @rank=:ace, @suit=:spades>, #<Card:0x007f938c8a85a0 @rank=9, @suit=:clubs>]"]
       
       (compared using ==)
       
       Diff:
       @@ -1,3 +1,2 @@
       -[#<Card:0x007f938c8a8640 @rank=:ace, @suit=:spades>,
       - #<Card:0x007f938c8a85a0 @rank=9, @suit=:clubs>]
       +["[#<Card:0x007f938c8a8640 @rank=:ace, @suit=:spades>, #<Card:0x007f938c8a85a0 @rank=9, @suit=:clubs>]"]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:400
     # /tmp/d20151112-27349-1giz2b5/spec.rb:11: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)>'

  37) 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
     NoMethodError:
       undefined method `rank' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:400
     # /tmp/d20151112-27349-1giz2b5/solution.rb:14:in `=='
     # /tmp/d20151112-27349-1giz2b5/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)>'

  38) SixtySixDeck behaves like a deck #size returns the size of the deck
     Failure/Error: expect(small_deck.size).to eq 2
       
       expected: 2
            got: 1
       
       (compared using ==)
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:400
     # /tmp/d20151112-27349-1giz2b5/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)>'

  39) SixtySixDeck behaves like a deck #draw_top_card pops the top-most card
     Failure/Error: expect(small_deck.draw_top_card).to eq ace_of_spades
       
       expected: #<Card:0x007f938cbf1c98 @rank=:ace, @suit=:spades>
            got: [#<Card:0x007f938cbf1c98 @rank=:ace, @suit=:spades>, #<Card:0x007f938cbf1ba8 @rank=9, @suit=:clubs>]
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,3 @@
       -#<Card:0x007f938cbf1c98 @rank=:ace, @suit=:spades>
       +[#<Card:0x007f938cbf1c98 @rank=:ace, @suit=:spades>,
       + #<Card:0x007f938cbf1ba8 @rank=9, @suit=:clubs>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:400
     # /tmp/d20151112-27349-1giz2b5/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)>'

  40) SixtySixDeck behaves like a deck #draw_bottom_card pops the bottom-most card
     Failure/Error: expect(small_deck.draw_bottom_card).to eq nine_of_clubs
       
       expected: #<Card:0x007f938d094b10 @rank=9, @suit=:clubs>
            got: [#<Card:0x007f938d094b38 @rank=:ace, @suit=:spades>, #<Card:0x007f938d094b10 @rank=9, @suit=:clubs>]
       
       (compared using ==)
       
       Diff:
       @@ -1,2 +1,3 @@
       -#<Card:0x007f938d094b10 @rank=9, @suit=:clubs>
       +[#<Card:0x007f938d094b38 @rank=:ace, @suit=:spades>,
       + #<Card:0x007f938d094b10 @rank=9, @suit=:clubs>]
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:400
     # /tmp/d20151112-27349-1giz2b5/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)>'

  41) SixtySixDeck behaves like a deck #top peeks at the top-most card
     Failure/Error: expect(small_deck.top_card).to eq ace_of_spades
     NoMethodError:
       undefined method `at' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:400
     # /tmp/d20151112-27349-1giz2b5/solution.rb:74:in `top_card'
     # /tmp/d20151112-27349-1giz2b5/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)>'

  42) SixtySixDeck behaves like a deck #bottom peeks at the bottom-most card
     Failure/Error: expect(small_deck.bottom_card).to eq nine_of_clubs
     NoMethodError:
       undefined method `at' for nil:NilClass
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:400
     # /tmp/d20151112-27349-1giz2b5/solution.rb:78:in `bottom_card'
     # /tmp/d20151112-27349-1giz2b5/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)>'

  43) SixtySixDeck behaves like a deck #to_s returns the names of the cards, each on its own line
     Failure/Error: expect(small_deck.to_s.strip).to eq "Ace of Spades\n9 of Clubs"
     NoMethodError:
       undefined method `strip' for #<Array:0x007f938d105d10>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1giz2b5/spec.rb:400
     # /tmp/d20151112-27349-1giz2b5/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)>'

  44) SixtySixDeck #sort sorts the cards in the defined order
     Failure/Error: expect(deck.sort.to_a).to eq [jack_of_spades, ten_of_hearts, ace_of_clubs, two_of_clubs]
       
       expected: [#<Card:0x007f938d1bd118 @rank=:jack, @suit=:spades>, #<Card:0x007f938d1bd0c8 @rank=10, @suit=:hearts>, #<Card:0x007f938d1bd140 @rank=:ace, @suit=:clubs>, #<Card:0x007f938d1bd0f0 @rank=9, @suit=:clubs>]
            got: [[#<Card:0x007f938d1bd140 @rank=:ace, @suit=:clubs>, #<Card:0x007f938d1bd118 @rank=:jack, @suit=:spades>, #<Card:0x007f938d1bd0f0 @rank=9, @suit=:clubs>, #<Card:0x007f938d1bd0c8 @rank=10, @suit=:hearts>]]
       
       (compared using ==)
       
       Diff:
       @@ -1,5 +1,5 @@
       -[#<Card:0x007f938d1bd118 @rank=:jack, @suit=:spades>,
       - #<Card:0x007f938d1bd0c8 @rank=10, @suit=:hearts>,
       - #<Card:0x007f938d1bd140 @rank=:ace, @suit=:clubs>,
       - #<Card:0x007f938d1bd0f0 @rank=9, @suit=:clubs>]
       +[[#<Card:0x007f938d1bd140 @rank=:ace, @suit=:clubs>,
       +  #<Card:0x007f938d1bd118 @rank=:jack, @suit=:spades>,
       +  #<Card:0x007f938d1bd0f0 @rank=9, @suit=:clubs>,
       +  #<Card:0x007f938d1bd0c8 @rank=10, @suit=:hearts>]]
     # /tmp/d20151112-27349-1giz2b5/spec.rb:415: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)>'

  45) SixtySixDeck hand #twenty? returns true for king and queen not of the trump suit
     Failure/Error: expect(hand.twenty?(:hearts)).to be true
     TypeError:
       no implicit conversion of Symbol into Array
     # /tmp/d20151112-27349-1giz2b5/solution.rb:297:in `-'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:297:in `twenty?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:439: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)>'

  46) SixtySixDeck hand #twenty? returns false for king and queen of the trump suit
     Failure/Error: expect(hand.twenty?(:clubs)).to be false
     TypeError:
       no implicit conversion of Symbol into Array
     # /tmp/d20151112-27349-1giz2b5/solution.rb:297:in `-'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:297:in `twenty?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:452: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)>'

  47) SixtySixDeck hand #twenty? returns false for hands without a king and queen of the same suit
     Failure/Error: expect(hand.twenty?(:hearts)).to be false
     TypeError:
       no implicit conversion of Symbol into Array
     # /tmp/d20151112-27349-1giz2b5/solution.rb:297:in `-'
     # /tmp/d20151112-27349-1giz2b5/solution.rb:297:in `twenty?'
     # /tmp/d20151112-27349-1giz2b5/spec.rb:465: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.06454 seconds
57 examples, 47 failures

Failed examples:

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

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

Пламена обнови решението на 11.11.2015 15:39 (преди около 9 години)

+class Card
+ attr_accessor :rank, :suit
+
+ def initialize(rank, suit)
+ @rank = rank
+ @suit = suit
+ end
+
+ def to_s
+ puts "#{rank.to_s.capitalize} of #{suit.to_s.capitalize}"
+ end
+
+ def ==(other)
+ @rank == other.rank and @suit == other.suit
+ end
+
+end
+
+class Deck < Card
+
+ include Enumerable
+ attr_accessor :cards, :ranks
+
+ def initialize(*cards_array, ranks)
+ @cards, @ranks = Array[], ranks
+ case cards_array.size
+ when 0
+ make_array_of_cards(ranks)
+ else
+ @cards = cards_array
+ end
+ end
+
+ def make_array_of_cards(ranks)
+ suits = [:spades, :hearts, :diamonds, :clubs]
+ suits.each do |suit|
+ ranks.size.times do |i|
+ @cards << Card.new( ranks[i], suit)
+ end
+ end
+ end
+
+ def each
+ current = 1
+ while current <= @cards.size
+ yield (@cards[current - 1]).to_s
+ current = current + 1
+ end
+ end
+
+ def to_s
+ @cards.each do |card|
+ card.to_s
+ end
+ end
+
+ def size
+ @cards.size
+ end
+
+ def draw_bottom_card
+ @cards.pop
+ end
+
+ def draw_top_card
+ @cards.shift
+ end
+
+ def shuffle
+ @cards.shuffle!
+ end
+
+ def top_card
+ @card.at(0)
+ end
+
+ def bottom_card
+ @card.at(-1)
+ end
+
+ def sort
+ suits = [:spades, :hearts, :diamonds, :clubs]
+ @cards.sort! do |x, y|
+ comp = (suits.index(x.suit) <=> suits.index(y.suit))
+ comp.zero? ? (ranks.index(y.rank) <=> ranks.index(x.rank)) : comp
+ end
+ end
+
+ def deal(amount_of_cards, players_deck)
+ amount_of_cards.times do
+ players_deck.cards.push(self.draw_top_card)
+ end
+ end
+end
+
+class WarDeck < Deck
+ def initialize(*args)
+ ranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, :jack, :queen, :king, :ace]
+ super(*args, ranks)
+ end
+
+ def deal
+ players_deck = WarPlayersDeck.new
+ super(26, players_deck)
+ players_deck
+ end
+
+ def sort
+ super()
+ end
+end
+
+class WarPlayersDeck < Deck
+ def initialize
+ @ranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, :jack, :queen, :king, :ace]
+ @cards = Array[]
+ end
+
+ def play_card
+ @cards.delete_at((0..(cards.size - 1)).to_a.sample)
+ end
+
+ def allow_face_up?
+ @cards.size <= 3
+ end
+end
+
+class BeloteDeck < Deck
+ def initialize(*args)
+ @ranks = [7, 8, 9, :jack, :queen, :king, 10, :ace]
+ super(*args, ranks)
+ end
+
+ def deal
+ players_deck = BelotePlayersDeck.new
+ super(8, players_deck)
+ players_deck
+ end
+
+ def sort
+ super()
+ end
+end
+
+
+class BelotePlayersDeck < Deck
+ def initialize
+ @ranks = [7, 8, 9, :jack, :queen, :king, 10, :ace]
+ @cards = Array[]
+ end
+
+ def sort
+ super()
+ end
+
+ def highest_of_suit(suit)
+ self.sort
+ (@cards.select {|card| card.suit == suit}).at(0)
+ end
+
+ def has?(suit, rank)
+ @cards.any? {|card| card.rank == rank && card.suit == suit}
+ end
+
+ def belote?
+ couples = 0
+ suits = [:spades, :hearts, :diamonds, :clubs]
+ suits.each do |suit|
+ if (has?(suit, :king) && has?(suit, :queen))
+ couples = couples + 1
+ end
+ end
+ couples > 0
+ end
+
+ def tierce?
+ tierce, suits = 0, [:spades, :hearts, :diamonds, :clubs]
+ ranks =[7, 8, 9, :jack, :queen, :king, 10, :ace]
+ suits.each do |suit|
+ count_three_in_a_row(ranks, suit)
+ end
+ tierce > 0
+ end
+
+ def count_three_in_a_row(ranks, suit)
+ ranks.each_c(3) do |c|
+ if (has?(suit, c.at(0))) &&
+ (has?(suit, c.at(1))) && (has?(suit, c.at(2)))
+ tierce = tierce + 1
+ end
+ end
+ end
+
+ def quarte?
+ quarte, suits = 0, [:spades, :hearts, :diamonds, :clubs]
+ ranks = [7, 8, 9, :jack, :queen, :king, 10, :ace]
+ suits.each do |suit|
+ count_four_in_a_row(ranks, suit)
+ end
+ quarte > 0
+ end
+
+ def count_four_in_a_row(ranks, suit)
+ ranks.each_c(4) do |c|
+ if (has?(suit, c.at(0))) && (has?(suit, c.at(1))) &&
+ (has?(suit, c.at(2))) && (has?(suit, c.at(3)))
+ quarte = quarte + 1
+ end
+ end
+ end
+
+ def quint?
+ quint, suits = 0, [:spades, :hearts, :diamonds, :clubs]
+ ranks = [7, 8, 9, :jack, :queen, :king, 10, :ace]
+ suits.each do |suit|
+ count_five_in_a_row(ranks, suit)
+ end
+ quint > 0
+ end
+
+ def count_five_in_a_row(ranks, suit)
+ ranks.each_c(5) do |c|
+ if has?(suit, c.at(0)) && has?(suit, c.at(1)) &&
+ has?(suit, c.at(2)) && has?(suit, c.at(3)) && has?(suit, c.at(4))
+ quint = quint + 1
+ end
+ end
+ end
+
+ def carre_of_jacks?
+ carre = 0
+ suits = [:spades, :hearts, :diamonds, :clubs]
+ suits.each do |suit|
+ if (has?(suit, :jack))
+ carre = carre + 1
+ end
+ end
+ carre == 4
+ end
+
+ def carre_of_nines?
+ carre = 0
+ suits = [:spades, :hearts, :diamonds, :clubs]
+ suits.each do |suit|
+ if (has?(suit, 9))
+ carre = carre + 1
+ end
+ end
+ carre == 4
+ end
+
+ def carre_of_aces?
+ carre = 0
+ suits = [:spades, :hearts, :diamonds, :clubs]
+ suits.each do |suit|
+ if (has?(suit, :ace))
+ carre = carre + 1
+ end
+ end
+ carre == 4
+ end
+end
+
+class SixtySixDeck < Deck
+ def initialize(*args)
+ @ranks = [9, :jack, :queen, :king, 10, :ace]
+ super(*args, ranks)
+ end
+
+ def deal
+ players_deck = SixtySixPlayersDeck.new
+ super(6, players_deck)
+ players_deck
+ end
+
+ def sort
+ super()
+ end
+end
+
+class SixtySixPlayersDeck < Deck
+ def initialize
+ @ranks = [9, :jack, :queen, :king, 10, :ace]
+ @cards = Array[]
+ end
+
+ def sort
+ super()
+ end
+
+ def has?(suit, rank)
+ @cards.any? {|card| card.rank == rank && card.suit == suit}
+ end
+
+ def twenty?(trump_suit)
+ couples = 0
+ suits = [:spades, :hearts, :diamonds, :clubs] - trump_suit
+ suits.each do |suit|
+ if (has?(suit, :king) && has?(suit, :queen))
+ couples = couples + 1
+ end
+ end
+ couples > 0
+ end
+
+ def forty?(trump_suit)
+ has?(suit, :king) && has?(suit, :queen)
+ end
+end

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

Вадиш резултати на екрана, вместо да ги връщаш като низ, което не е окей.

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