Previous Entry Share Next Entry
Code Golf: 99 Bottles Of Beer
Balgove
tobyaw
I’m now feeling slightly addicted to Code Golf puzzles. I managed to create the smallest (so far) Ruby implementation of the 99 Bottles Of Beer problem, shaving 2 bytes off the previous best.

a='#{n} bottle#{:s if n>1} of beer on the wall'
puts eval'"%s, %s.
#{n-=1;n>0?"Take one down and pass it around":(n=99;"Go to the store and buy some more")}, %s.

"'%[a,a[0,31],a]*n=99


Now on to another problem to think about over the weekend - I think I’ll tackle Numeric Diamonds next.

Meanwhile, qidane and I managed to recover some files from e_halmac’s dead external hard disk. Hopefully we managed to get the important ones. So it feels like we’ve done our good deed for the week.

?

Log in

No account? Create an account