Michael Morin wrote:
> I did something slightly different, which works on multiple levels, not
> just two.  For example, it can go all the way up to 999 without any
> extra code.
> 
> [...]

Unfortunately your implemention fails with multiples of 100.

Being the lazy guy I just used the excellent [Ruby Lingustics 
Framework][1] to deduce English numerals.  The following program 
produces the [full 99 Bottles of Beer lyrics][2] with numerals:

---
require 'Linguistics'
Linguistics::use(:en)

class Fixnum
  def bottles
    case self
      when 0: "no more bottles"
      when 1: "one bottle"
      else    "#{self.en.numwords} bottles"
    end
  end
end

99.downto(0) do |n|
  puts "#{n.bottles.capitalize} of beer on the wall, #{n.bottles} of 
beer."
  if n > 0
    puts "Take one down and pass it around, #{(n-1).bottles} of beer on 
the wall."
    puts
  else
    puts "Go to the store and buy some more, #{99.bottles} of beer on 
the wall."
  end
end
---

Regards,
Matthias

[1]: http://www.deveiate.org/projects/Linguistics/
[2]: http://99-bottles-of-beer.net/lyrics.html
-- 
Posted via http://www.ruby-forum.com/.