------art_117803_24777850.1165862733476
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Thanks, this was fun!

class Tournament
  attr_reader :list

  def initialize players
    raise "Must be a positive number of players" if players < 1
    @players  layers
    @list  rray.new(players) { |i| i+1 }

    # Add 'bye's up to the next power of 2
    next_power   ** sprintf("%b",players).length
    unless players next_power / 2
      (players+1).upto(next_power) { @list << 'bye' }
    end
    @list  enerate @list
  end

  def generate list
    len  ist.length
    return list if len < 
    left  ist[0..(len/4-1)]+list[-(len/4)..-1]
    right ist[(len/4)..-(len/4+1)]
    [generate(left),generate(right)]
  end
end

puts "Test tournaments from 1 to 16 in size:"
1.upto(16) do |players|
  puts Tournament.new(players).list.inspect
end

------art_117803_24777850.1165862733476--