How to resolve the algorithm 99 bottles of beer step by step in the Huginn programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm 99 bottles of beer step by step in the Huginn programming language
Table of Contents
Problem Statement
Display the complete lyrics for the song: 99 Bottles of Beer on the Wall.
The lyrics follow this form: ... and so on, until reaching 0 (zero). Grammatical support for 1 bottle of beer is optional. As with any puzzle, try to do it in as creative/concise/comical a way as possible (simple, obvious solutions allowed, too).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm 99 bottles of beer step by step in the Huginn programming language
Source code in the huginn programming language
#! /bin/sh
exec huginn --no-argv -E "${0}" "${@}"
#! huginn
import Algorithms as algo;
main() {
x = "{} bottle{} of beer on the wall,\n"
"{} bottle{} of beer.\n"
"Take one down, pass it around,\n"
"{} bottle{} of beer on the wall.\n\n";
for ( n : algo.range( 99, 0, -1 ) ) {
bot = n > 0 ? n : "No";
plu = n != 1 ? "s" : "";
print( x.format( bot, plu, bot, plu, n > 1 ? n - 1 : "No", n != 2 ? "s" : "" ) );
}
print(
"No bottles of beer on the wall,\n"
"No bottles of beer.\n"
"Go to the store, buy some more,\n"
"99 bottles of beer on the wall.\n"
);
return ( 0 );
}
You may also check:How to resolve the algorithm Jump anywhere step by step in the VBScript programming language
You may also check:How to resolve the algorithm I before E except after C step by step in the Perl programming language
You may also check:How to resolve the algorithm Generic swap step by step in the REXX programming language
You may also check:How to resolve the algorithm Sierpinski triangle step by step in the Pascal programming language
You may also check:How to resolve the algorithm Set step by step in the Nanoquery programming language