Twelve Days Kata

Cyber Dojo - Katas

The Twelve Days of Christmas Kata

What's the SMALLEST (line count) program that can produce the classic Christmas song lyrics? With just a bit of tweeking I got it down to 117 lines... I'm sure you can do better.

Go give it a try - Cyber Dojo

The Cyber Dojo (just became my favorite tool) has the lyrics in a readme.txt file for you when you select the Twelve Days Kata from it's library of programming exercises. Just to let you know the lyrics are 113 lines long...

But the exercise is not to write dense code - like I did to get down to 117... but to start refactoring the redundant lines of the code - into I would guess... loops inside of loops... inside... it's loops all the way down.

On the first day of Christmas

My true love gave to me:

A partridge in a pear tree.


On the second day of Christmas

My true love gave to me:

Two turtle doves and

A partridge in a pear tree.


On the third day of Christmas

My true love gave to me:

Three french hens

Two turtle doves and

A partridge in a pear tree.


On the forth day of Christmas

My true love gave to me:

Four calling birds

Three french hens

Two turtle doves and

A partridge in a pear tree.


On the fifth day of Christmas

My true love gave to me:

Five golden rings

Four calling birds

Three french hens

Two turtle doves and

A partridge in a pear tree.


On the sixth day of Christmas,

My true love gave to me:

Six geese a-laying

Five golden rings

Four calling birds

Three french hens

Two turtle doves and

A partridge in a pear tree.


On the seventh day of Christmas,

My true love gave to me:

Seven swans a-swimming

Six geese a-laying

Five golden rings

Four calling birds

Three french hens

Two turtle doves and

A partridge in a pear tree.


On the eight day of Christmas,

My true love gave to me:

Eight maids a-milking

Seven swans a-swimming

Six geese a-laying

Five golden rings

Four calling birds

Three french hens

Two turtle doves and

A partridge in a pear tree.


On the ninth day of Christmas,

My true love gave to me:

Nine ladies dancing

Eight maids a-milking

Seven swans a-swimming

Six geese a-laying

Five golden rings

Four calling birds

Three french hens

Two turtle doves and

A partridge in a pear tree.


On the tenth day of Christmas,

My true love gave to me:

Ten lords a-leaping

Nine ladies dancing

Eight maids a-milking

Seven swans a-swimming

Six geese a-laying

Five golden rings

Four calling birds

Three french hens

Two turtle doves and

A partridge in a pear tree.


On the eleventh day of Christmas,

My true love gave to me:

Eleven pipers piping

Ten lords a-leaping

Nine ladies dancing

Eight maids a-milking

Seven swans a-swimming

Six geese a-laying

Five golden rings

Four calling birds

Three french hens

Two turtle doves and

A partridge in a pear tree.


On the Twelfth day of Christmas,

My true love gave to me:

Twelve drummers drumming

Eleven pipers piping

Ten lords a-leaping

Nine ladies dancing

Eight maids a-milking

Seven swans a-swimming

Six geese a-laying

Five golden rings

Four calling birds

Three french hens

Two turtle doves

And a partridge in a pear tree.