How to resolve the algorithm The Twelve Days of Christmas step by step in the Pointless 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 Pointless 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 Pointless programming language
Source code in the pointless programming language
output =
range(1, 12)
|> map(makeVerse)
|> join("\n\n")
|> print
days = {
1: "first",
2: "second",
3: "third",
4: "fourth",
5: "fifth",
6: "sixth",
7: "seventh",
8: "eighth",
9: "ninth",
10: "tenth",
11: "eleventh",
12: "twelfth"
}
verseFormat = """On the {} day of Christmas
My true love gave to me:
{}"""
makeVerse(n) =
format(verseFormat,
[getDefault(days, "", n),
makeGifts(n)])
gifts = [
"A partridge in a pear tree.",
"Two turtle doves and",
"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",
]
makeGifts(n) =
gifts
|> take(n)
|> reverse
|> join("\n")
You may also check:How to resolve the algorithm 99 bottles of beer step by step in the Nim programming language
You may also check:How to resolve the algorithm Square form factorization step by step in the J programming language
You may also check:How to resolve the algorithm Sorting algorithms/Shell sort step by step in the Perl programming language
You may also check:How to resolve the algorithm Loops/Do-while step by step in the Elixir programming language
You may also check:How to resolve the algorithm Apply a callback to an array step by step in the Nim programming language