How to resolve the algorithm The Twelve Days of Christmas step by step in the Vim Script 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 Vim Script 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 Vim Script programming language
Source code in the vim programming language
let b:days=["first", "second", "third", "fourth", "fifth", "sixth",
\ "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"]
let b:gifts=[
\ "And a partridge in a pear tree.",
\ "Two turtle doves,",
\ "Three french hens,",
\ "Four calling birds,",
\ "Five golden rings,",
\ "Six geese a-laying,",
\ "Seven swans a-swimming,",
\ "Eight maids a-milking,",
\ "Nine ladies dancing,",
\ "Ten lords a-leaping,",
\ "Eleven pipers piping,",
\ "Twelve drummers drumming,"
\ ]
function Nth(n)
echom "On the " . b:days[a:n] . " day of Christmas, my true love gave to me:"
endfunction
call Nth(0)
echom toupper(strpart(b:gifts[0], 4, 1)) . strpart(b:gifts[0], 5)
let b:day = 1
while (b:day < 12)
echom " "
call Nth(b:day)
let b:gift = b:day
while (b:gift >= 0)
echom b:gifts[b:gift]
let b:gift = b:gift - 1
endwhile
let b:day = b:day + 1
endwhile
You may also check:How to resolve the algorithm Random Latin squares step by step in the C++ programming language
You may also check:How to resolve the algorithm Sierpinski triangle step by step in the Go programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the Gambas programming language
You may also check:How to resolve the algorithm Singly-linked list/Element definition step by step in the Python programming language
You may also check:How to resolve the algorithm Filter step by step in the Clean programming language