Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.

2009/12/21

The 12 Days: an analysis

Using this code:

  1. #!/usr/bin/perl  
  2.   
  3. use 5.010 ;  
  4. use strict ;  
  5. use warnings ;  
  6. use DateTime::TimeZone ;  
  7. use File::stat ;  
  8.   
  9. my @count ;  
  10. my @days ;  
  11.   
  12. $days[1] = 'Partridge in a Pear Tree' ;  
  13. $days[2] = 'Turtle Doves' ;  
  14. $days[3] = 'French Hens' ;  
  15. $days[4] = 'Calling Birds' ;  
  16. $days[5] = 'Golden Rings' ;  
  17. $days[6] = 'Geese A-laying' ;  
  18. $days[7] = 'Swans A-swimming' ;  
  19. $days[8] = 'Maids A-milking' ;  
  20. $days[9] = 'Ladies Dancing' ;  
  21. $days[10] = 'Lords A-leaping' ;  
  22. $days[11] = 'Pipers Piping' ;  
  23. $days[12] = 'Drummers Drumming' ;  
  24.   
  25. for my $a ( 1 .. 12 ) {  
  26.     for my $b ( 1 .. 12 ) {  
  27.         next if $b > $a ;  
  28.         $count[$b] ++ ;  
  29.         }  
  30.     }  
  31.   
  32. for my $a ( 1 .. 12 ) {  
  33.     say join ' ' , $count[$a] * $a , $days[$a] ;  
  34.     }  


I determined the precise number of each gift as presented in the song.


12 Partridge in a Pear Tree
22 Turtle Doves
30 French Hens
36 Calling Birds
40 Golden Rings
42 Geese A-laying
42 Swans A-swimming
40 Maids A-milking
36 Ladies Dancing
30 Lords A-leaping
22 Pipers Piping
12 Drummers Drumming

I suppose it preferable to have a smaller number of drummers than geese. Time to get into the geese and swan market, though.

No comments:

Post a Comment