How to resolve the algorithm The Twelve Days of Christmas step by step in the Logo 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 Logo 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 Logo programming language
Source code in the logo programming language
make "numbers [first second third fourth fifth sixth seventh eighth ninth tenth eleventh twelfth]
make "gifts [[And a partridge in a pear tree] [Two turtle doves] [Three French hens]
[Four calling birds] [Five gold rings] [Six geese a-laying]
[Seven swans a-swimming] [Eight maids a-miling] [Nine ladies dancing]
[Ten lords a-leaping] [Eleven pipers piping] [Twelve drummers drumming]]
to nth :n
print (sentence [On the] (item :n :numbers) [day of Christmas, my true love sent to me])
end
nth 1
print [A partridge in a pear tree]
for [d 2 12] [
print []
nth :d
for [g :d 1] [
print item :g gifts
]
]
bye
You may also check:How to resolve the algorithm Roots of unity step by step in the Lambdatalk programming language
You may also check:How to resolve the algorithm Fibonacci n-step number sequences step by step in the VBScript programming language
You may also check:How to resolve the algorithm Non-decimal radices/Convert step by step in the C# programming language
You may also check:How to resolve the algorithm Euler's identity step by step in the Lambdatalk programming language
You may also check:How to resolve the algorithm Balanced brackets step by step in the SETL programming language