Code Golfing

Recently I was directed the the code golf on stackexchange: http://codegolf.stackexchange.com/  it’s pretty interesting to read other people submissions. I decided to take a crack at the 12 days of christmas submission http://codegolf.stackexchange.com/questions/4191/12-days-of-christmas-lyrics

 

My answer in JavaScript

 

var l=["first","second","third","fourth","fifth","sixth","seventh","eight","ninth","tenth","eleventh","twelfth","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"];var b = "<br/>";for(var i=0;i<12;i++){var p="On the "+l[i]+"day of Christmas"+b+"My true love gave to me"+b;for(var x=i;x>0;x--)p+=l[11+x]+b;if(i>0)p+="and ";p+="a partridge in a pear tree"+b+b;document.write(p);}

Leave a Reply

*



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">