How to resolve the algorithm The Twelve Days of Christmas step by step in the zkl 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 zkl 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 zkl programming language

Source code in the zkl programming language

gifts:=
#<<<
"A beer, in a tree.; Two turtlenecks; Three french toast;
Four pounds of backbacon; Five golden touques; Six packs of two-four; 
Seven packs of smokes; Eight comic books; Nine back up singers;
Ten feet of snow; Eleven hosers hosing; Twelve dozen donuts"
#<<<
.split(";").apply("strip");

days:=("first second third fourth fifth sixth seventh eighth ninth tenth "
      "eleventh twelfth").split();
 
foreach n,day in (days.enumerate()){ n+=1;
   g:=gifts[0,n].reverse();
   println("On the %s day of Christmas\nMy true love gave to me:\n".fmt(day),
         g[0,-1].concat("\n"), (n>1) and " and\n" or "", g[-1], "\n");
}

  

You may also check:How to resolve the algorithm Rot-13 step by step in the Objeck programming language
You may also check:How to resolve the algorithm Dot product step by step in the Arturo programming language
You may also check:How to resolve the algorithm File size step by step in the Liberty BASIC programming language
You may also check:How to resolve the algorithm Guess the number/With feedback step by step in the Pascal programming language
You may also check:How to resolve the algorithm Greatest common divisor step by step in the Oforth programming language