Golf!

Code:
$w=" on the wall";$i=99;print$i.&s."$w, $i".&s.". ".(--$i?"Take one down and pass it around, $i":'Go to the store and buy some more, 99').&s."$w."while$i;sub s{' bottle'.($i!=1?'s':'').' of beer'}

197. I (more like, this guy I know) wins!
 
Last edited:
growse said:
Code:
$w=" on the wall";$i=99;print$i.&s."$w, $i".&s.". ".(--$i?"Take one down and pass it around, $i":'Go to the store and buy some more, 99').&s."$w."while$i;sub s{' bottle'.($i!=1?'s':'').' of beer'}

197. I (more like, this guy I know) wins!

Perl should be banned from Golf competitions :(
 
growse said:
Code:
$w=" on the wall";$i=99;print$i.&s."$w, $i".&s.". ".(--$i?"Take one down and pass it around, $i":'Go to the store and buy some more, 99').&s."$w."while$i;sub s{' bottle'.($i!=1?'s':'').' of beer'}

197. I (more like, this guy I know) wins!

Hate to be a pedant, but this solution's output formatting is wrong so doesn't quite qualify IMHo. It doesn not have any line breaks whatsoever whereas the model output has line breaks and a blank line between each iteration. (That said, it's not going to make much of a difference to the size :) )

Edit: Added "output" into the explanation otherwise it was a bit ambiguous.
 
Last edited:
Back
Top Bottom