[WARNING: ONE LINE POST] Code Golf: 99 Bottles (JS: 182 bytes)

This is one line, but a surprising amount of effort went into this one little line.

For those unfamiliar with Code Golf, the goal is to make a program complete a given task in the smallest amount of bytes.

The challenge I took on was the 99 Bottles song. The program must output this song:

``````99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.
...

2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.``````

Keep in mind plurals.

I actually did this some time ago, and @Kognise and I actually combined our solutions. Unfortunately I realized that solution didn't output the lyrics correctly. So I present to you, my best solution I could create in 182 bytes in JS.

``for(i=99;i>0;i--)console.log(`\${a=' bottle',b=a+(i>1?'s':''),c=' of beer',d=' on the wall',i+b+c}\${d}, \${i+b+c}.\nTake one down and pass it around, \${i>1?i-1:'no more'}\${a}s\${c+d}.`)``

This is code at it's most cursed.

You are viewing a single comment. View All
sycrepl (10)

Tried my best but couldn't do better, here's the code if you want, it sucks

``for(i=99;i>0;i--)console.log(`\${s=`\${i} bottle\${i>1?"s":""}`} of beer on the wall, \${s} of beer.\nTake one down, pass it around, \${i>1?s=`\${i - 1} bottle\${i>1?"s":""}`:"no more bottles"} of beer on the wall.`)``
Zavexeon (1132)

@sycrepl It passes the cursed code test.