Skip to content

Instantly share code, notes, and snippets.

@fourseven
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save fourseven/9864748 to your computer and use it in GitHub Desktop.

Select an option

Save fourseven/9864748 to your computer and use it in GitHub Desktop.

Revisions

  1. Mathew Hartley revised this gist Mar 29, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 99_bottles.rb
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    def b i=1,w=nil
    "#{i} bottle#{i==1 ?'':'s'} of beer#{w ?" on the wall":''}"
    "#{i} bottle#{:s if i>1} of beer#{" on the wall" if w}"
    end
    puts *99.downto(2).map {|n| "#{b n,1}, #{b n}.\nTake one down and pass it around, #{b n-1,1}.\n\n"}
    puts "#{b 1,1}, #{b}.\nGo to the store and buy some more, #{b 99,1}.\n\n"
  2. Mathew Hartley created this gist Mar 29, 2014.
    5 changes: 5 additions & 0 deletions 99_bottles.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    def b i=1,w=nil
    "#{i} bottle#{i==1 ?'':'s'} of beer#{w ?" on the wall":''}"
    end
    puts *99.downto(2).map {|n| "#{b n,1}, #{b n}.\nTake one down and pass it around, #{b n-1,1}.\n\n"}
    puts "#{b 1,1}, #{b}.\nGo to the store and buy some more, #{b 99,1}.\n\n"