Skip to main content
1 of 10

Powershell - 542

$a=('and a 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')

    
0..11 | % {
    'On the {0} day of christmas my true love gave to me {1}' -f (
                (
                    'first',
                    'second',
                    'third',
                    'fourth',
                    'fifth',
                    'sixth',
                    'seventh',
                    'eighth',
                    'ninth',
                    'tenth',
                    'eleventh',
                    'twelveth'
                )[$_],
            ($_ | %{
                    switch($_){
                        0 { $a[0].Substring(4) }
                        default {
                            $_..0 | % {$a[$_]} | out-string
                        }
                        }
                   }
            )
     )
}    }