## Calling all programmers
Code a puzzle 4 Xmas
_[The Twelve Days of Christmas](https://en.wikipedia.org/wiki/Twelve_Days_of_Christmas)_
_According to the traditional song, on the first day of Christmas (25th December), my true love sent to me:_
* _A partridge in a pear tree_
_On the second day of Christmas (26th December), my true love sent to me THREE presents:_
* _Two turtle doves_
* _A partridge in a pear tree_
_On the third day of Christmas (27th December and so on) my true love sent to me SIX presents:_
* _Three French hens_
* _Two turtle doves_
* _A partridge in a pear tree_
_This carries on until the the twelfth day of Christmas, when my true love sends 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 gold rings_
* _Four calling birds_
* _Three French hens_
* _Two turtle doves_
* _A partridge in a pear tree_
_Puzzle Author: Stephen Froggatt_
1. Strict, hard coded, solution:
```
function allgifts()
dg = [] # daily gifts storage
for d in 1:12
d = sum(1:d) # daily gifts from day 1 to 12
push!(dg, d) # storing each day gifts
end
print(sum(dg)) # showing total number of gifts in storage
end
# > allgifts()
# 364
```
2. Generalizing the function for any number of days:
```
# I'll put here my solution (in Julia) on the twelfth day
```
**Meanwhile, I invite you all to post in the comments some solution coded in the programming language of your choice**
#math #puzzle #invitation #teaser #programmers #programming #code #christmas #days
@Pat I assure you do not have to to go back to the 70s to write a solution. 😉
I first went to Mathlab, but then thought it would be more fun to use something completely unsuited to the task, like AWK or BASH.
Are you looking for code for a function similar to the hard-coded solution in your example, or are you looking for some kind of mathematical shortcut using factorials or calculus or something?
(I'm not a math gal but I'm sure this must be a well-known series in mathematics, with the name of some old mathematician tacked on to it.)
@Pat
You may find it hard to believe, but I'm making this for fun, in the spirit of the season.
As you've been so kind to offer me the choice, AWK please. 😃
(Yes, it's similar to "a well known series in mathematics, with the name of some old mathematician..." 🤭 )