How to resolve the algorithm The Twelve Days of Christmas step by step in the PureBasic programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm The Twelve Days of Christmas step by step in the PureBasic programming language

Table of Contents

Problem Statement

Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here.
(You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.)

Let's start with the solution:

Step by Step solution about How to resolve the algorithm The Twelve Days of Christmas step by step in the PureBasic programming language

Source code in the purebasic programming language

#TXT$ = "On the * day of Christmas, my true love sent to me:"
days$ = ~"first\nsecond\nthird\nfourth\nfifth\nsixth\nseventh\neighth\nninth\ntenth\neleventh\ntwelfth\n"
gifts$= ~"Twelve drummers drumming,\nEleven pipers piping,\nTen lords a-leaping,\nNine ladies dancing,\n"+
        ~"Eight maids a-milking,\nSeven swans a-swimming,\nSix geese a-laying,\nFive golden rings,\n"+
        ~"Four calling birds,\nThree french hens,\nTwo turtle doves,\nA partridge in a pear tree.\n"
Define  I.i, J.i

If OpenConsole("The twelve days of Christmas")
  For I = 1 To 12
    PrintN(ReplaceString(#TXT$,"*",StringField(days$,I,~"\n")))    
    For J = 13-I To 12      
      PrintN(" -> "+StringField(gifts$,J,~"\n"))
    Next J    
  Next I
  Input()
EndIf

  

You may also check:How to resolve the algorithm Nth root step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Largest int from concatenated ints step by step in the Python programming language
You may also check:How to resolve the algorithm Luhn test of credit card numbers step by step in the Standard ML programming language
You may also check:How to resolve the algorithm Heronian triangles step by step in the Racket programming language
You may also check:How to resolve the algorithm Legendre prime counting function step by step in the Chapel programming language