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

Published on 12 May 2024 09:40 PM

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

Source code in the crystal programming language

99.downto(1) do |n|                                                             
  puts "#{n} bottle#{n > 1 ? "s" : ""} of beer on the wall"                     
  puts "#{n} bottle#{n > 1 ? "s" : ""} of beer"                                 
  puts "Take one down, pass it around"                                          
  puts "#{n-1} bottle#{n > 2 ? "s" : ""} of beer on the wall\n\n" if n > 1      
end                                                                             
puts "No more bottles of beer on the wall"


  

You may also check:How to resolve the algorithm Array concatenation step by step in the Amazing Hopper programming language
You may also check:How to resolve the algorithm Mutual recursion step by step in the AWK programming language
You may also check:How to resolve the algorithm Sum of squares step by step in the bc programming language
You may also check:How to resolve the algorithm Box the compass step by step in the Sidef programming language
You may also check:How to resolve the algorithm Formatted numeric output step by step in the Seed7 programming language