How to resolve the algorithm 99 bottles of beer step by step in the Inform 7 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm 99 bottles of beer step by step in the Inform 7 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 Inform 7 programming language

Source code in the inform programming language

Beer Hall is a room.

When play begins:
	repeat with iteration running from 1 to 99:
		let N be 100 - iteration;
		say "[N] bottle[s] of beer on the wall[line break]";
		say "[N] bottle[s] of beer[line break]";
		say "Take one down, pass it around[line break]";
		say "[N - 1] bottle[s] of beer on the wall[paragraph break]";
	end the story.

Beer Hall is a room.

The plural of bottle of beer is bottles of beer. A bottle of beer is a kind of thing.

The wall is a scenery supporter in Beer Hall. 99 bottles of beer are on the wall.

When play begins:
	while something is on the wall:
		say "[what's on the wall] on the wall[line break]";
		say "[what's on the wall][line break]";
		say "Take one down, pass it around[line break]";
		remove a random thing on the wall from play;
		say "[what's on the wall] on the wall[paragraph break]";
	end the story.

To say what's on the wall:
	if more than one thing is on the wall, say list of things on the wall;
	otherwise say "[number of things on the wall in words] bottle[s] of beer".

  

You may also check:How to resolve the algorithm Special variables step by step in the Lingo programming language
You may also check:How to resolve the algorithm Literals/Integer step by step in the Clojure programming language
You may also check:How to resolve the algorithm Langton's ant step by step in the CoffeeScript programming language
You may also check:How to resolve the algorithm Stirling numbers of the first kind step by step in the Ruby programming language
You may also check:How to resolve the algorithm Create a file step by step in the Modula-3 programming language