From: tamouse mailing lists Date: 2013-03-26T21:33:39+09:00 Subject: Re: Chris Pine Tutorial 99 Bottles of Beer Program On Tue, Mar 26, 2013 at 7:08 AM, tamouse mailing lists wrote: > On Tue, Mar 26, 2013 at 2:00 AM, Phil H. wrote: >> Hello all, this is what I came up with, works great. >> >> bottles_of_beer = 99 >> while bottles_of_beer > 1 >> puts bottles_of_beer.to_s + ' bottles of beer on the wall, ' + >> bottles_of_beer.to_s + ' bottles of beer' >> bottles_of_beer = bottles_of_beer - 1 >> puts 'You take one down, pass it around, ' + bottles_of_beer.to_s + ' >> bottles of beer on the wall.' >> end >> >> puts 'Everyone passes out quite drunk.' > > def beersong(n=99) > n.downto(1) do |i| > puts < #{i} bottles of beer on the wall, > #{i} bottles of beer! > Take one down, pass it around, > #{i > 2 ? i-1 : "no more"} bottles of beer! AAUGH, off by one: #{i>1 ? i-1 : "No more"} bottles of beer! > > SONG > end > puts "... and they all fell down drunk!" > end