OK here's a good one for you.
Santa delivers presents to each house in turn. He has been told that every family lives on one long street with numbers starting at 1. He starts with number 1, and delivers 1 present to number 1.
Unfortunately, however, the children are greedy and each house expects more presents than the last. Many times more, in fact.
They are so greedy that the children in each house expect
their house number times the amount of presents as the last. So the child in number 3 expects 6 presents. The child in number 4 expects 24 presents. The children in number 5 expect 120 presents. [You can probably see where this is going.]
Part 1
Santa soon realises that the number of presents is going to get quite large and realises he will be better off getting his super elves to deal with them. Each superelf can take any number of batches of a million presents at ridiculous speed (but can't take any less than a million and can only take exact multiples of a million). Santa will have to deal with the remainder himself.
How many presents in total will Santa have to deliver himself? (Assume he can arrange all the elves prior to starting out any deliveries, i.e. the answer is by definition less than a million)
[On my machine my implementation takes
well under a second - insignificant
]
Part 2
Unfortunately, Santa still has to wrap all the presents before he sets out.
To his computer's relief, and being the brexiteer that he is, Santa decides to sod europe and just concentrate on Britain. He estimates (possibly incorrectly) that the number of households is
around 30 million (your puzzle input). Again, he (possibly incorrectly) assumes that every family lives on one long street numbered from 1 to about 30million.
He approximates the amount of wrapping paper in metres for the nth household by how hot his computer's RAM chip is getting when it stores the number of presents for that household, which is proportional to how many bits are lit up.
For the first and second households (1, 2 presents respectively), he orders 1 metre each. For the 3rd and 4th household (6, 24 presents respectively), he orders 2 metres. For the 5th and 6th households, he orders 4 metres. etc.
How many metres does he need to order for the Nth household
(just for the Nth household this time - not the total for all households!)
- where N (your puzzle input) = (pick one and stick to it)
etc
[On my machine my implementation takes
]
Part 3
Santa decides to type out the total number of presents for the Nth household. This in itself is thirsty work, so Santa's wife decides to go and get Santa a cup of tea whenever she sees Santa type the digits "123" together. How many cups of tea does Santa end up drinking?
(Assume that Santa's wife is a very very quick tea maker and the time it takes her is negligible, so if Santa encounters 123 twice, e.g. 123123, then he will neck two cups of tea on the trot, etc.)
[On my machine my implementation takes
]