Last active
December 22, 2020 15:51
-
-
Save barrault01/15c5a9f55ea68080ff01fee6bf7094d6 to your computer and use it in GitHub Desktop.
This file contains 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
var alreadyGave = [String]() | |
let formatter = NumberFormatter() | |
formatter.numberStyle = .ordinal | |
[ | |
"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-milking", | |
"Nine ladies dancing", | |
"Ten lords a-leaping", | |
"Eleven pipers piping", | |
"Twelve drummers drumming" | |
].forEach { | |
alreadyGave.append($0.lowercased()) | |
let dayOf = formatter.string(for: alreadyGave.count)! | |
print("On the \(dayOf) day of Christmas, my true love sent to me: ") | |
if alreadyGave.count > 1 { | |
print(alreadyGave | |
.reversed() | |
.dropLast() | |
.joined(separator: ", ") + " and " + alreadyGave.first!) | |
} else { | |
print($0) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment