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

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
Kognise (389)

LMAO I have the exact same code in a repl from 2 months ago :P

https://repl.it/@Kognise/Beer

Zavexeon (1015)

@Kognise Wait what? (Oh wait, yeah remember when we did that code golf and combined our code, did you copy and paste mine for better reference?)

Edit: No longer exact anyways, just realized this also sings the song wrong. Had to add two extra bytes to fix smh.

Kognise (389)

@Zavexeon idk anymore

(plagiarism somewhere, I can feel it)

Zavexeon (1015)

@Kognise I did use elements from your solution (such as defining variables in the template literal) but I didn't copy and paste anything, I wrote it all out.