주인장 혼자 끙끙댄 걸로는 Perl 223바이트가 한계. 1등은 170바이트인데 도대체 53글자를 어디서 줄인다냐 -_-;
# 줄바꿈을 전부 없애면 223바이트 $B=" on the wall"; sub b{"$_[0] bottle".(($_[0]>1)?"s":"")." of beer"} print b($_),"$B, ",b($_),".\n", (($_>1)?"Take one down and pass it around, ":"Go to the store and buy some more, "), b($_-1||99),"$B.\n\n" for reverse(1..99)
이건 안된다는군요...
#!/usr/bin/perl use LWP::Simple; my $a=get "http://codegolf.com/competition/output/99-bottles-of-beer"; $a=~s/\<.+\>//g; print $a;
음 역시나 찾아보니 "You will be unable to import/require/include any modules or files in your solution. You have to write all the code yourself, and it has to be in the code file you upload."
http://99-bottles-of-beer.net/language-perl-737.html
저는 역시 길이 없는 데서 길을 만드는 건 못하는 것 같아요 흐... 일단 방향이 주어지면 거기서 어떻게든 줄이는 건 하겠는데.
Alternative Versions를 참고해서 196자까지는 만들어봤습니다.
$y=99; $B=" on the wall"; sub b{$n=$y||99;"$n bottle"."s"x!!--$n." of beer"} print b,"$B, ",b,".\n", --$y?"Take one down and pass it around, ":"Go to the store and buy some more, ", b,"$B.\n\n" while $y
오오 조프님 불타오르시는군요!
"s"x!!(--$n) 이라니... 절로 고개가 숙여지는군요.
sub'b{[@b=(abs||99,bottle."s"x!!++$_,of,beer),on,the,wall]} print "@{+b}, @b.\n" .($_?"Take one down and pass it around":"Go to the store and buy some more") .", @{+b}.\n\n"for-99..-1
음, Take one 어쩌고 하는 라인의 앞뒤를, .으로 스트링 붙이기를 하지 않고 쉼표로 구분하면 괄호를 없앨 수 있으니 2글자 줄일 수 있군요.
괄호 제거, print 직후의 공백 제거, 그리고 "\n"을 코드 자체의 줄바꿈으로 처리해서 174바이트짜리:
sub b{[@b=(abs||99,bottle."s"x!!++$_,of,beer),on,the,wall]}print"@{+b}, @b. ",$_?"Take one down and pass it around":"Go to the store and buy some more",", @{+b}. "for-99..-14글자를 도대체 어디에서 더 제거할 수 있을 것인가!! 아니면 170자짜리가 되려면 이런 형태에서는 불가능하고 처음부터 뜯어고쳐야 할지도?
(코드 적는데는 코멘트 매크로가 방해만 되는 터라, 매크로 없앴습니다)