Skip to content

Instantly share code, notes, and snippets.

@danudey
Last active August 29, 2015 14:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danudey/710d0d437a78009c5371 to your computer and use it in GitHub Desktop.
Save danudey/710d0d437a78009c5371 to your computer and use it in GitHub Desktop.
Twelve lines of Christmas
#!/usr/bin/env python
gifts = ("partridge in a pear tree", "turtle doves", "french hens",
"calling birds", "golden rings", "geese-a-laying", "swans-a-swimming",
"maids-a-milking", "ladies dancing", "lords-a-leaping", "pipers piping",
"drummers drumming",)
for i in xrange(1,len(gifts)+1):
print "On the {} day of Christmas, my true love gave to me:".format(
str(i)+("th" if 4<=i%100<=20 else {1:"st",2:"nd",3:"rd"}.get(i%10, "th")))
for j, gift in list(enumerate(gifts[:i],1))[::-1]:
print " {} {}".format((j,("and a","a")[i==1])[j==1], gift)
print
@danudey
Copy link
Author

danudey commented Dec 20, 2014

Notes:

  1. Fits in twelve lines
  2. Fits in 80 chars/line (but only because I use two-space indents)
  3. Ugly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment