Last active
November 19, 2015 13:15
-
-
Save svenluijten/72883fbaa70eb89f5a3b to your computer and use it in GitHub Desktop.
99 Bottles of Beer (http://codegolf.stackexchange.com/questions/64198/99-bottles-of-beer)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 99 bottles of beer song in 251 bytes. --> | |
<?php for($i=99;$i>0;$i--){$b=" of beer";$s=" bottles$b";$r=" bottle$b";$w=" on the wall";$h=$i-1;echo$h>=1?"$i$s$w, $i$s.\nTake one down and pass it around, $h".($h<2?$r:$s)."$w.\n\n":"$i$r$w, $i$r. \nGo to the store and buy some more, 99$s$w.\n\n";} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// The unminified version. | |
for ($i=99; $i > 0; $i--) { | |
$b = " of beer"; | |
$s = " bottles$b"; | |
$r = " bottle$b"; | |
$w = " on the wall"; | |
$h = $i - 1; | |
echo $h >= 1 ? "$i$s$w, $i$s.\nTake one down and pass it around, $h" . ($h<2 ? $r : $s) . "$w.\n\n" : "$i$r$w, $i$r. \nGo to the store and buy some more, 99$s$w. \n\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment