Решение на Четвърта задача от Петър Нетовски

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

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

Резултати

  • 6 точки от тестове
  • 1 отнета точка
  • 5 точки общо
  • 54 успешни тест(а)
  • 3 неуспешни тест(а)

Код

class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
@rank = rank
@suit = suit
end
def to_s
"#{@rank.to_s.capitalize} of #{@suit.capitalize}"
end
def ==(other)
@suit == other.suit && @rank == other.rank
end
end
class Deck
include Enumerable
attr_accessor :deck
def get_suits
[:spades, :hearts, :diamonds, :clubs]
end
def get_ranks
[2, 3, 4, 5, 6, 7, 8, 9, 10, :jack, :queen, :king, :ace].reverse
end
def get_standard_deck
standard_deck = []
ranks_and_suits = get_suits.product(get_ranks)
ranks_and_suits.each do |rank_and_suit|
standard_deck << Card.new(rank_and_suit[1], rank_and_suit[0])
end
standard_deck
end
def initialize(deck = get_standard_deck)
@deck = deck
end
def size
@deck.size
end
def draw_top_card
@deck.shift
end
def draw_bottom_card
@deck.pop
end
def top_card
@deck.first
end
def bottom_card
@deck.last
end
def shuffle
@deck.shuffle!
end
def sort
@deck.sort_by! { |card| get_ranks.find_index(card.rank) }
@deck.sort_by! { |card| get_suits.find_index(card.suit) }
end
def to_s
@deck
end
def deal
@deck.shift(deck.size)
end
def each
current_card = 0
while current_card < @deck.size
yield @deck[current_card]
current_card += 1
end
end
private
def get_occurring_ranks_by_suit(suit)
occurrences = Hash.new(0)
get_ranks.each do |rank|
card = Card.new(rank, suit)
if not @deck.include?(card)
occurrences[rank] = 0
elsif @deck[@deck.find_index(card)].rank == rank
occurrences[rank] += 1
end
end
occurrences
end
def highest_consecutive_by_suit(hand_by_suit)
consecutive = 0
max_consecutive = 0
get_ranks.each do |rank|
consecutive = (hand_by_suit[rank] == 1) ? consecutive + 1 : 0
max_consecutive = consecutive if consecutive > max_consecutive
end
max_consecutive
end
end
class WarDeck < Deck
private
class WarHand < WarDeck
def self.size
26
end
def play_card
card = @deck.sample
@deck.delete(card)
card
end
def allow_face_up?
@deck.size <= 3
end
end
public
def deal
WarHand.new(@deck.shift(WarHand.size))
end
end
class BeloteDeck < Deck
def get_ranks
[7, 8, 9, :jack, :queen, :king, 10, :ace].reverse
end
private
class BeloteHand < BeloteDeck
def self.size
8
end
def highest_of_suit(suit)
array = @deck.select { |card| card.suit == suit }
array.sort_by! { |card| get_ranks.find_index(card.rank) }
array[0]
end
def belote?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
return true
end
end
false
end
def tierce?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if highest_consecutive_by_suit(hand_by_suit) > 2
return true
end
end
false
end
def quarte?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if highest_consecutive_by_suit(hand_by_suit) > 3
return true
end
end
false
end
def quint?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if highest_consecutive_by_suit(hand_by_suit) > 4
return true
end
end
false
end
def get_occurring_ranks_for_all_suits
occurrences = Hash.new(0)
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
occurrences.merge!(hand_by_suit) { |key, first, second| first + second }
end
occurrences
end
def carre_of_jacks?
hand = get_occurring_ranks_for_all_suits
return true if hand[:jack] == 4
false
end
def carre_of_nines?
hand = get_occurring_ranks_for_all_suits
return true if hand[9] == 4
false
end
def carre_of_aces?
hand = get_occurring_ranks_for_all_suits
return true if hand[:ace] == 4
false
end
end
public
def deal
BeloteHand.new(@deck.shift(BeloteHand.size))
end
end
class SixtySixDeck < Deck
def get_ranks
[9, :jack, :queen, :king, 10, :ace].reverse
end
private
class SixtySixHand < SixtySixDeck
def self.size
6
end
def twenty?(trump_suit)
suits = get_suits
suits.delete(trump_suit)
suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
return true
end
end
false
end
def forty?(trump_suit)
hand_by_suit = get_occurring_ranks_by_suit(trump_suit)
return true if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
false
end
end
public
def deal
SixtySixHand.new(@deck.shift(SixtySixHand.size))
end
end

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

...........F............F..........................F.....

Failures:

  1) 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:0x007f844d3a3fa8>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1wyj2h4/spec.rb:140
     # /tmp/d20151112-27349-1wyj2h4/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)>'

  2) 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:0x007f844d2e56e8>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1wyj2h4/spec.rb:191
     # /tmp/d20151112-27349-1wyj2h4/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)>'

  3) 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:0x007f844d0a2a70>
     Shared Example Group: "a deck" called from /tmp/d20151112-27349-1wyj2h4/spec.rb:400
     # /tmp/d20151112-27349-1wyj2h4/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)>'

Finished in 0.04049 seconds
57 examples, 3 failures

Failed examples:

rspec /tmp/d20151112-27349-1wyj2h4/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-1wyj2h4/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-1wyj2h4/spec.rb:67 # SixtySixDeck behaves like a deck #to_s returns the names of the cards, each on its own line

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

Петър обнови решението на 10.11.2015 22:55 (преди около 9 години)

+class Card
+ attr_accessor :rank, :suit
+
+ public
+
+ def initialize(rank, suit)
+ @rank = rank
+ @suit = suit
+ end
+
+ def to_s
+ "#{@rank.to_s.capitalize} of #{@suit.capitalize}"
+ end
+
+ def ==(other)
+ @suit == other.suit && @rank == other.rank
+ end
+end
+
+class Deck
+ include Enumerable
+
+ attr_accessor :deck
+
+ public
+
+ def get_suits
+ [:spades, :hearts, :diamonds, :clubs]
+ end
+
+ def get_ranks
+ [2, 3, 4, 5, 6, 7, 8, 9, 10, :jack, :queen, :king, :ace].reverse
+ end
+
+ def get_standard_deck
+ suits = get_suits
+ ranks = get_ranks
+
+ standard_deck = []
+ ranks_and_suits = suits.product(ranks)
+
+ ranks_and_suits.each do |rank_and_suit|
+ standard_deck << Card.new(rank_and_suit[1], rank_and_suit[0])
+ end
+
+ standard_deck
+ end
+
+ def initialize(deck = get_standard_deck)
+ @deck = deck
+ end
+
+ def size
+ @deck.size
+ end
+
+ def draw_top_card
+ @deck.shift
+ end
+
+ def draw_bottom_card
+ @deck.pop
+ end
+
+ def top_card
+ @deck.first
+ end
+
+ def bottom_card
+ @deck.last
+ end
+
+ def shuffle
+ @deck.shuffle!
+ end
+
+ def sort
+ @deck.sort_by! { |card| get_ranks.find_index(card.rank) }
+ @deck.sort_by! { |card| get_suits.find_index(card.suit) }
+ end
+
+ def to_s
+ @deck
+ end
+
+ def deal
+ @deck.shift(deck.size)
+ end
+
+ def each
+ current_card = 0
+ while current_card < @deck.size
+ yield @deck[current_card]
+ current_card += 1
+ end
+ end
+
+ private
+
+ def get_occurring_ranks_by_suit(suit)
+ occurrences = Hash.new(0)
+ get_ranks.each do |rank|
+ card = Card.new(rank, suit)
+ if not @deck.include?(card)
+ occurrences[rank] = 0
+ elsif @deck[@deck.find_index(card)].rank == rank
+ occurrences[rank] += 1
+ end
+ end
+
+ occurrences
+ end
+
+ def highest_consecutive_by_suit(hand_by_suit)
+ consecutive = 0
+ max_consecutive = 0
+ get_ranks.each do |rank|
+ consecutive = (hand_by_suit[rank] == 1) ? consecutive + 1 : 0
+ max_consecutive = consecutive if consecutive > max_consecutive
+ end
+
+ max_consecutive
+ end
+end
+
+class WarDeck < Deck
+
+ private
+
+ class WarHand < WarDeck
+ def self.size
+ 26
+ end
+
+ def play_card
+ card = @deck.sample
+ @deck.delete(card)
+ card
+ end
+
+ def allow_face_up?
+ @deck.size <= 3
+ end
+ end
+
+ public
+
+ def deal
+ WarHand.new(@deck.shift(WarHand.size))
+ end
+end
+
+class BeloteDeck < Deck
+ def get_ranks
+ [7, 8, 9, :jack, :queen, :king, 10, :ace].reverse
+ end
+
+ private
+
+ class BeloteHand < BeloteDeck
+ def self.size
+ 8
+ end
+
+ def highest_of_suit(suit)
+ array = @deck.select { |card| card.suit == suit }
+ array.sort_by! { |card| get_ranks.find_index(card.rank) }
+ array[0]
+ end
+
+ def belote?
+ get_suits.each do |suit|
+ hand_by_suit = get_occurring_ranks_by_suit(suit)
+ if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
+ return true
+ end
+ end
+ false
+ end
+
+ def tierce?
+ get_suits.each do |suit|
+ hand_by_suit = get_occurring_ranks_by_suit(suit)
+ if highest_consecutive_by_suit(hand_by_suit) > 2
+ return true
+ end
+ end
+ false
+ end
+
+ def quarte?
+ get_suits.each do |suit|
+ hand_by_suit = get_occurring_ranks_by_suit(suit)
+ if highest_consecutive_by_suit(hand_by_suit) > 3
+ return true
+ end
+ end
+ false
+ end
+
+ def quint?
+ get_suits.each do |suit|
+ hand_by_suit = get_occurring_ranks_by_suit(suit)
+ if highest_consecutive_by_suit(hand_by_suit) > 4
+ return true
+ end
+ end
+ false
+ end
+
+ def get_occurring_ranks_for_all_suits
+ occurrences = Hash.new(0)
+ get_suits.each do |suit|
+ hand_by_suit = get_occurring_ranks_by_suit(suit)
+ occurrences.merge!(hand_by_suit) { |key, first, second| first + second }
+ end
+
+ occurrences
+ end
+
+ def carre_of_jacks?
+ hand = get_occurring_ranks_for_all_suits
+ return true if hand[:jack] == 4
+ false
+ end
+
+ def carre_of_nines?
+ hand = get_occurring_ranks_for_all_suits
+ return true if hand[9] == 4
+ false
+ end
+
+ def carre_of_aces?
+ hand = get_occurring_ranks_for_all_suits
+ return true if hand[:ace] == 4
+ false
+ end
+ end
+
+ public
+
+ def deal
+ BeloteHand.new(@deck.shift(BeloteHand.size))
+ end
+end
+
+class SixtySixDeck < Deck
+ def get_ranks
+ [9, :jack, :queen, :king, 10, :ace].reverse
+ end
+
+ private
+
+ class SixtySixHand < SixtySixDeck
+ def self.size
+ 6
+ end
+
+ def twenty?(trump_suit)
+ suits = get_suits
+ suits.delete(trump_suit)
+ suits.each do |suit|
+ hand_by_suit = get_occurring_ranks_by_suit(suit)
+ if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
+ return true
+ end
+ end
+ false
+ end
+
+ def forty?(trump_suit)
+ hand_by_suit = get_occurring_ranks_by_suit(trump_suit)
+ return true if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
+ false
+ end
+ end
+
+ public
+
+ def deal
+ SixtySixHand.new(@deck.shift(SixtySixHand.size))
+ end
+end

Петър обнови решението на 10.11.2015 22:58 (преди около 9 години)

class Card
attr_accessor :rank, :suit
public
def initialize(rank, suit)
@rank = rank
@suit = suit
end
def to_s
"#{@rank.to_s.capitalize} of #{@suit.capitalize}"
end
def ==(other)
@suit == other.suit && @rank == other.rank
end
end
class Deck
include Enumerable
attr_accessor :deck
public
def get_suits
[:spades, :hearts, :diamonds, :clubs]
end
def get_ranks
[2, 3, 4, 5, 6, 7, 8, 9, 10, :jack, :queen, :king, :ace].reverse
end
def get_standard_deck
- suits = get_suits
- ranks = get_ranks
-
standard_deck = []
- ranks_and_suits = suits.product(ranks)
+ ranks_and_suits = get_suits.product(get_ranks)
ranks_and_suits.each do |rank_and_suit|
standard_deck << Card.new(rank_and_suit[1], rank_and_suit[0])
end
standard_deck
end
def initialize(deck = get_standard_deck)
@deck = deck
end
def size
@deck.size
end
def draw_top_card
@deck.shift
end
def draw_bottom_card
@deck.pop
end
def top_card
@deck.first
end
def bottom_card
@deck.last
end
def shuffle
@deck.shuffle!
end
def sort
@deck.sort_by! { |card| get_ranks.find_index(card.rank) }
@deck.sort_by! { |card| get_suits.find_index(card.suit) }
end
def to_s
@deck
end
def deal
@deck.shift(deck.size)
end
def each
current_card = 0
while current_card < @deck.size
yield @deck[current_card]
current_card += 1
end
end
private
def get_occurring_ranks_by_suit(suit)
occurrences = Hash.new(0)
get_ranks.each do |rank|
card = Card.new(rank, suit)
if not @deck.include?(card)
occurrences[rank] = 0
elsif @deck[@deck.find_index(card)].rank == rank
occurrences[rank] += 1
end
end
occurrences
end
def highest_consecutive_by_suit(hand_by_suit)
consecutive = 0
max_consecutive = 0
get_ranks.each do |rank|
consecutive = (hand_by_suit[rank] == 1) ? consecutive + 1 : 0
max_consecutive = consecutive if consecutive > max_consecutive
end
max_consecutive
end
end
class WarDeck < Deck
private
class WarHand < WarDeck
def self.size
26
end
def play_card
card = @deck.sample
@deck.delete(card)
card
end
def allow_face_up?
@deck.size <= 3
end
end
public
def deal
WarHand.new(@deck.shift(WarHand.size))
end
end
class BeloteDeck < Deck
def get_ranks
[7, 8, 9, :jack, :queen, :king, 10, :ace].reverse
end
private
class BeloteHand < BeloteDeck
def self.size
8
end
def highest_of_suit(suit)
array = @deck.select { |card| card.suit == suit }
array.sort_by! { |card| get_ranks.find_index(card.rank) }
array[0]
end
def belote?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
return true
end
end
false
end
def tierce?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if highest_consecutive_by_suit(hand_by_suit) > 2
return true
end
end
false
end
def quarte?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if highest_consecutive_by_suit(hand_by_suit) > 3
return true
end
end
false
end
def quint?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if highest_consecutive_by_suit(hand_by_suit) > 4
return true
end
end
false
end
def get_occurring_ranks_for_all_suits
occurrences = Hash.new(0)
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
occurrences.merge!(hand_by_suit) { |key, first, second| first + second }
end
occurrences
end
def carre_of_jacks?
hand = get_occurring_ranks_for_all_suits
return true if hand[:jack] == 4
false
end
def carre_of_nines?
hand = get_occurring_ranks_for_all_suits
return true if hand[9] == 4
false
end
def carre_of_aces?
hand = get_occurring_ranks_for_all_suits
return true if hand[:ace] == 4
false
end
end
public
def deal
BeloteHand.new(@deck.shift(BeloteHand.size))
end
end
class SixtySixDeck < Deck
def get_ranks
[9, :jack, :queen, :king, 10, :ace].reverse
end
private
class SixtySixHand < SixtySixDeck
def self.size
6
end
def twenty?(trump_suit)
suits = get_suits
suits.delete(trump_suit)
suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
return true
end
end
false
end
def forty?(trump_suit)
hand_by_suit = get_occurring_ranks_by_suit(trump_suit)
return true if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
false
end
end
public
def deal
SixtySixHand.new(@deck.shift(SixtySixHand.size))
end
end

Петър обнови решението на 10.11.2015 23:03 (преди около 9 години)

class Card
attr_accessor :rank, :suit
- public
-
def initialize(rank, suit)
@rank = rank
@suit = suit
end
def to_s
"#{@rank.to_s.capitalize} of #{@suit.capitalize}"
end
def ==(other)
@suit == other.suit && @rank == other.rank
end
end
class Deck
include Enumerable
attr_accessor :deck
-
- public
def get_suits
[:spades, :hearts, :diamonds, :clubs]
end
def get_ranks
[2, 3, 4, 5, 6, 7, 8, 9, 10, :jack, :queen, :king, :ace].reverse
end
def get_standard_deck
standard_deck = []
ranks_and_suits = get_suits.product(get_ranks)
ranks_and_suits.each do |rank_and_suit|
standard_deck << Card.new(rank_and_suit[1], rank_and_suit[0])
end
standard_deck
end
def initialize(deck = get_standard_deck)
@deck = deck
end
def size
@deck.size
end
def draw_top_card
@deck.shift
end
def draw_bottom_card
@deck.pop
end
def top_card
@deck.first
end
def bottom_card
@deck.last
end
def shuffle
@deck.shuffle!
end
def sort
@deck.sort_by! { |card| get_ranks.find_index(card.rank) }
@deck.sort_by! { |card| get_suits.find_index(card.suit) }
end
def to_s
@deck
end
def deal
@deck.shift(deck.size)
end
def each
current_card = 0
while current_card < @deck.size
yield @deck[current_card]
current_card += 1
end
end
private
def get_occurring_ranks_by_suit(suit)
occurrences = Hash.new(0)
get_ranks.each do |rank|
card = Card.new(rank, suit)
if not @deck.include?(card)
occurrences[rank] = 0
elsif @deck[@deck.find_index(card)].rank == rank
occurrences[rank] += 1
end
end
occurrences
end
def highest_consecutive_by_suit(hand_by_suit)
consecutive = 0
max_consecutive = 0
get_ranks.each do |rank|
consecutive = (hand_by_suit[rank] == 1) ? consecutive + 1 : 0
max_consecutive = consecutive if consecutive > max_consecutive
end
max_consecutive
end
end
class WarDeck < Deck
private
class WarHand < WarDeck
def self.size
26
end
def play_card
card = @deck.sample
@deck.delete(card)
card
end
def allow_face_up?
@deck.size <= 3
end
end
public
def deal
WarHand.new(@deck.shift(WarHand.size))
end
end
class BeloteDeck < Deck
def get_ranks
[7, 8, 9, :jack, :queen, :king, 10, :ace].reverse
end
private
class BeloteHand < BeloteDeck
def self.size
8
end
def highest_of_suit(suit)
array = @deck.select { |card| card.suit == suit }
array.sort_by! { |card| get_ranks.find_index(card.rank) }
array[0]
end
def belote?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
return true
end
end
false
end
def tierce?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if highest_consecutive_by_suit(hand_by_suit) > 2
return true
end
end
false
end
def quarte?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if highest_consecutive_by_suit(hand_by_suit) > 3
return true
end
end
false
end
def quint?
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if highest_consecutive_by_suit(hand_by_suit) > 4
return true
end
end
false
end
def get_occurring_ranks_for_all_suits
occurrences = Hash.new(0)
get_suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
occurrences.merge!(hand_by_suit) { |key, first, second| first + second }
end
occurrences
end
def carre_of_jacks?
hand = get_occurring_ranks_for_all_suits
return true if hand[:jack] == 4
false
end
def carre_of_nines?
hand = get_occurring_ranks_for_all_suits
return true if hand[9] == 4
false
end
def carre_of_aces?
hand = get_occurring_ranks_for_all_suits
return true if hand[:ace] == 4
false
end
end
public
def deal
BeloteHand.new(@deck.shift(BeloteHand.size))
end
end
class SixtySixDeck < Deck
def get_ranks
[9, :jack, :queen, :king, 10, :ace].reverse
end
private
class SixtySixHand < SixtySixDeck
def self.size
6
end
def twenty?(trump_suit)
suits = get_suits
suits.delete(trump_suit)
suits.each do |suit|
hand_by_suit = get_occurring_ranks_by_suit(suit)
if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
return true
end
end
false
end
def forty?(trump_suit)
hand_by_suit = get_occurring_ranks_by_suit(trump_suit)
return true if hand_by_suit[:king] > 0 && hand_by_suit[:queen] > 0
false
end
end
public
def deal
SixtySixHand.new(@deck.shift(SixtySixHand.size))
end
end
  • в sort разчиташ, че сортировката в Руби е стабилна, но това може да не е така; аз не съм сигурен в това;
  • array е много лошо име на променлива
  • Deck#each методът ти може да се напише много по-елегантно;
  • имаш проблеми със спазването на конвенциите на места, направи справка с ръководството за стил

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