Hello folks,
Did we write 99 bottles of beer coding quest before? Here is the lyrics:
Quote
The music
https://www.youtube.com/watch?v=FITjBet3dio
The music with some performance :D
https://www.youtube.com/watch?v=xCHYR3wRQLQ
I don't remember when I did run across this site 99 Bottles of Beer (https://www.99-bottles-of-beer.net/) but it seems fun.
So here is my snippet:
; _________________________________________________________________________
; initialized variables
.data
sverse1 db "%s bottle%s of beer on the wall, %s bottle%s of beer.", 13, 10, 0
sverse2 db "Take one down and pass it around, %s bottle%s of beer on the wall.", 13, 10, 13, 10, 0
sverse3 db "Go to the store and buy some more, 99 bottles of beer on the wall.", 13, 10, 13, 10, 0
nBeer dq 99
empty db 0
; _________________________________________________________________________
; uninitialized variables
.data?
CommandLine LPSTR ?
hInstance HINSTANCE ?
NumArgs DWORD ?
sBeer1 db 3 dup(?)
sBeer2 db 3 dup(?)
.code
main proc argc:DWORD,argv:LPSTR
.while(nBeer {} -1)
invoke sprintf, addr sBeer1,"%d", nBeer
mov r15, nBeer
dec r15
invoke sprintf, addr sBeer2,"%d", r15
.if nBeer == 2
invoke printf, addr sverse1, addr sBeer1, "s", addr sBeer1, "s"
invoke printf, addr sverse2, addr sBeer2, addr empty
.elseif nBeer == 1
invoke printf, addr sverse1, addr sBeer1, addr empty, addr sBeer1, addr empty
invoke printf, addr sverse2, "no more", "s"
.elseif nBeer == 0
invoke printf, addr sverse1, "No more", "s", "no more", "s"
invoke printf, addr sverse3
.else
invoke printf, addr sverse1, addr sBeer1, "s", addr sBeer1, "s"
invoke printf, addr sverse2, addr sBeer2, "s"
.endif
sub nBeer,1
.endw
waitkey
.exit
ret
main endp
great :thumbsup:
Thank you daydreamer.
I hope people share their version of this challenge. @jj2007 always share something original :cool:
include \masm32\MasmBasic\MasmBasic.inc
Init
For_ ecx=99 To 2 Step -1
Print Str$("%i bottles of beer on the wall,", ecx), Str$(" %i bottles of beer.\n", ecx)
Print Str$("Take one down and pass it around, %i bottles of beer on the wall.\n\n", ecx-1)
Next
PrintLine "No more bottles of beer on the wall, no more bottles of beer."
Inkey "Go to the store and buy some more, 99 bottles of beer on the wall."
EndOfCode
Output looks identical to me, please check and let me know if something is missing :cool:
What programming language has the shortest 'Hello World' program? (https://www.quora.com/What-programming-language-has-the-shortest-Hello-World-program/answer/Devin-McGinty)
Quotehq9+ is an esoteric language with only four commands: 'h' prints "hello, world", 'q' prints the program's source (Quine), '9' prints the lyrics to 99 bottles of beer, and '+' increments the accumulator. hq9+ was pretty much made as a joke to cheat at code golf. So the hello world is just:
h
:biggrin:
https://esolangs.org/wiki/HQ9%2B
Attached a 22 lines implementation of hq9+ :cool:
C++ needs 51 lines. There is a 15 lines Applesoft BASIC implementation at https://esolangs.org/wiki/HQ9%2B, but user Yes cheats with multiple commands on some lines. The Python implementation does it in 16 lines, though :thumbsup:
Hello jj
In your first program you have missed the line which should start with 1 bottle of beer and you should print 1 bottle, not bottles!
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
In your second program there 's a redundant plural s after 1 bottles. In english people say 1 bottle, not bottles!
2 bottles of beer on the wall, 2 bottles of beer.
Take one down and pass it around, 1 bottles of beer on the wall.
1 bottles of beer on the wall, 1 bottles of beer.
Take one down and pass it around, 0 bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
Quote from: jj2007 on November 19, 2022, 12:51:07 PM
What programming language has the shortest 'Hello World' program? (https://www.quora.com/What-programming-language-has-the-shortest-Hello-World-program/answer/Devin-McGinty)
Quotehq9+ is an esoteric language with only four commands: 'h' prints "hello, world", 'q' prints the program's source (Quine), '9' prints the lyrics to 99 bottles of beer, and '+' increments the accumulator. hq9+ was pretty much made as a joke to cheat at code golf. So the hello world is just:
h
Esoteric languages always impress me! So if I did not get it wrong, hq9+ language's sole purpose is print hello world and the song lyrics of 99 bottles of beer?
@bluedevil, don't forget 'q' also prints the programs source. :tongue:
Seems that any of these could be done in masm with macros. :biggrin:
If external file is allowed
in Celse if(c[i]=='Q') system("type HQ9+.c");
:tongue:
22 lines of code
Quote from: bluedevil on November 20, 2022, 01:34:47 AM
Hello jj
In your first program you have missed the line which should start with 1 bottle of beer and you should print 1 bottle, not bottles!
You are right, that was sloppy coding :rolleyes:
include \masm32\MasmBasic\MasmBasic.inc
Init
Cls 7
For_ ecx=4 To 1 Step -1
.if ecx==1
Print cfm$("1 bottle of beer on the wall, 1 bottle of beer.\n")
.else
Print Str$("%i bottles of beer on the wall,", ecx), Str$(" %i bottles of beer.\n", ecx)
.endif
.if ecx==2
Print cfm$("Take one down and pass it around, 1 bottle of beer on the wall.\n\n")
.else
Print Str$("Take one down and pass it around, %i bottles of beer on the wall.\n\n", ecx-1)
.endif
Next
PrintLine "No more bottles of beer on the wall, no more bottles of beer."
Inkey "Go to the store and buy some more, 99 bottles of beer on the wall."
EndOfCode4 bottles of beer on the wall, 4 bottles of beer.
Take one down and pass it around, 3 bottles of beer on the wall.
3 bottles of beer on the wall, 3 bottles of beer.
Take one down and pass it around, 2 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, 0 bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
Now we need a line by line scrolling text of the song, accompanied by a synced MP3 of it playing in the background sung by a group of drunkards. :toothy: Beyond my coding capabilities, btw. :tongue:
I saw mentioned a compressed text strings, so we have use pen and paper for it :azn:
Perhaps repeated parts can connected.
EDIT
https://stackoverflow.com/questions/32576203/trying-to-code-the-99-bottles-of-beer-song
Quote from: zedd151 on November 21, 2022, 12:46:04 AM
Now we need a line by line scrolling text of the song, accompanied by a synced MP3 of it playing in the background sung by a group of drunkards. :toothy: Beyond my coding capabilities, btw. :tongue:
I thought that was made Saturday evening while party record singing, and change text from "press any key" to "don't sing off key" :tongue:
:greenclp:
I hope this challenge is open to think outside the box,99 bottles with a twist, not create program with exact same output?
here is my way,english isnt my native language
Quote from: daydreamer on November 21, 2022, 02:47:09 AMI hope this challenge is open to think outside the box,99 bottles with a twist, not create program with exact same output?
here is my way,english isnt my native language
I am tempted to write a macro that converts 25 to "twenty-five" :tongue:
switch seconddigit
case 2
print "twenty"
case 3
print "thirty"
case 4
print "forty"
case 5
print "fifty"
There it is (http://masm32.com/board/index.php?topic=10499.0), the NumberAsText$ macro :tongue:
Ninety-Nine bottles of beer on the wall, ninety-nine bottles of beer.
Take one down and pass it around, ninety-eight bottles of beer on the wall.
Ninety-Eight bottles of beer on the wall, ninety-eight bottles of beer.
Take one down and pass it around, ninety-seven bottles of beer on the wall.
...
Two bottles of beer on the wall, two bottles of beer.
Take one down and pass it around, 1 bottle of beer on the wall.
One bottle of beer on the wall, one bottle of beer.
Take one down and pass it around, bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and buy some more, 99 bottles of beer on the wall.
include \masm32\MasmBasic\MasmBasic.inc
Init
For_ ecx=99 To 1 Step -1
.if ecx==1
Print cfm$("One bottle of beer on the wall, one bottle of beer.\n")
.else
Print TitleCase$(NumberAsText$(ecx))
PrintLine " bottles of beer on the wall, ", NumberAsText$(ecx), " bottles of beer."
.endif
.if ecx==2
Print cfm$("Take one down and pass it around, 1 bottle of beer on the wall.\n\n")
.else
lea eax, [ecx-1]
PrintLine "Take one down and pass it around, ", NumberAsText$(eax), cfm$(" bottles of beer on the wall.\n")
.endif
Next
PrintLine "No more bottles of beer on the wall, no more bottles of beer."
Inkey "Go to the store and buy some more, 99 bottles of beer on the wall."
EndOfCode
Quote from: daydreamer on November 21, 2022, 02:47:09 AM
Quote from: zedd151 on November 21, 2022, 12:46:04 AM
Now we need a line by line scrolling text of the song, accompanied by a synced MP3 of it playing in the background sung by a group of drunkards. :toothy: Beyond my coding capabilities, btw. :tongue:
I thought that was made Saturday evening while party record singing, and change text from "press any key" to "don't sing off key" :tongue:
:greenclp:
I hope this challenge is open to think outside the box,99 bottles with a twist, not create program with exact same output?
here is my way,english isnt my native language
Hello @daydreamer
I love the way do it. But you have missed things?
1. New lines. After two line there should be a newline
2. You should decrement bottle number in the second line, look:
three bottles of beer on the wall. three bottles of beer.
take one down and pass it around. three bottles of beer on the wall
Look at your second line, you took one and pass it around[the bottle], and you have still three bottles. It should be two bottles.
Quote from: bluedevil on November 21, 2022, 05:16:16 PM
Quote from: daydreamer on November 21, 2022, 02:47:09 AM
Quote from: zedd151 on November 21, 2022, 12:46:04 AM
Now we need a line by line scrolling text of the song, accompanied by a synced MP3 of it playing in the background sung by a group of drunkards. :toothy: Beyond my coding capabilities, btw. :tongue:
I thought that was made Saturday evening while party record singing, and change text from "press any key" to "don't sing off key" :tongue:
:greenclp:
I hope this challenge is open to think outside the box,99 bottles with a twist, not create program with exact same output?
here is my way,english isnt my native language
Hello @daydreamer
I love the way do it. But you have missed things?
1. New lines. After two line there should be a newline
2. You should decrement bottle number in the second line, look:
three bottles of beer on the wall. three bottles of beer.
take one down and pass it around. three bottles of beer on the wall
Look at your second line, you took one and pass it around[the bottle], and you have still three bottles. It should be two bottles.
@jj2007, this is beautiful, you only missed "no more" here:
One bottle of beer on the wall, one bottle of beer.
Take one down and pass it around, bottles of beer on the wall.
^
no more
Hi
I corrected some and progressed with 99 bottles of sake :greenclp:
Quote from: daydreamer on November 23, 2022, 05:44:28 AM
Hi
I corrected some and progressed with 99 bottles of sake :greenclp:
sake? I am in. But where is the code. Let us try the codes.
:biggrin:
Try is with 99 bottles of Raki but I doubt you would make it to bottle 99. :tongue:
Quote from: bluedevil on November 23, 2022, 07:06:52 AM
Quote from: daydreamer on November 23, 2022, 05:44:28 AM
Hi
I corrected some and progressed with 99 bottles of sake :greenclp:
sake? I am in. But where is the code. Let us try the codes.
Updated previous zip file with two proc's
Japanese version of numbers to text and alternative 99 bottles of sake in karaoke bar
Quote from: hutch-- on November 23, 2022, 10:50:12 AM
:biggrin:
Try is with 99 bottles of Raki but I doubt you would make it to bottle 99. :tongue:
:eusa_dance:
When I was younger, yes I can finish the 99th bottle(but only the 99th), but now i could not finish even only one! :bgrin: thanks for reminding :D