Last active
January 18, 2017 21:09
-
-
Save zntfdr/237f393d241d1126c1ce3190f1dce690 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let gifts = [ "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" ] | |
let nth = [ "first", "second", "third", "fourth", "fifth", "sixth", | |
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth" ] | |
func gifts(for day: Int) -> String { | |
var result = "On the \(nth[day-1]) day of Christmas, my true love sent to me:\n" | |
if day > 1 { | |
for again in 1...day-1 { // . | |
let n = day - again // __/ \__ | |
result += gifts[n] // \ / / / | |
if n > 1 { result += "," } // /.'o'.\ /| /| _ _ _ | |
result += "\n" // .o.'. / |/ | (/_/ (_/ (_(_/ | |
} // .'.'o'. `-' `-' ,- / | |
result += "And a " // o'.o.'.o. _/,' /) _/_ | |
} else { // .'.o.'.'.o. / /_ _ . _ / _ _ __ _ | |
result += "A " // .o.'.o.'.o.'. ( / (_/ (_(_/ )_(_/ / /_(_(_/_) | |
} // [_____] `-' | |
return result + gifts[0] + ".\n" // \___/ | |
} | |
for day in 1...12 { | |
print(gifts(for: day)) | |
} |
golden rings
@patrickkim : fixed, thanks!
@bottomoftheheap9000: immensely haha
This is nitpicky, but there are two extra spaces on line 2 before "Six geese...."
@jasef: they were there because I've added en
in golden rings
a few hours ago, thanks for noticing! (fixed)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how bored are you