Skip to content

Instantly share code, notes, and snippets.

@dball
Created January 4, 2011 18:47
Show Gist options
  • Save dball/765193 to your computer and use it in GitHub Desktop.
Save dball/765193 to your computer and use it in GitHub Desktop.
class Deal
attr_accessor :clubs
def initialize
@players = (1..4)
@clubs = Array.new(13, @players.first)
end
def succ!
@clubs.each_with_index do |player, i|
if player != @players.last
@clubs[i] = player += 1
return self
else
@clubs[i] = @players.first
end
end
nil
end
def winner
players_lowest_clubs = Array.new(@players.to_a.length)
@clubs.each_with_index do |player, i|
players_lowest_clubs[player - 1] ||= i + 1
end
players_lowest_clubs.compact.max
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment