Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2015 Day 20, Part 1.
Here's why I'm posting instead of Bubbler and why not emanresuA
To keep the Elves busy, Santa has them deliver some presents by hand, door-to-door. He sends them down a street with infinite houses numbered sequentially: 1, 2, 3, 4, 5, and so on.
Each Elf is assigned a number, too, and delivers presents to houses based on that number. Instead of giving out presents at fixed intervals, Santa decides to give them out in longer and longer intervals because apparently he's short of supplies right now. Ignore the fact that the total number of presents delivered is the same after all :P
- The first Elf (number 1) delivers presents to the houses numbered 1, 1+2, 1+2+3, 1+2+3+4, 1+2+3+4+5, ... (1, 3, 6, 10, 15, ...)
- The second Elf (number 2) delivers presents to the houses numbered 2, 2+3, 2+3+4, 2+3+4+5, 2+3+4+5+6, ... (2, 5, 9, 14, 20, ...)
- Elf number 3 delivers presents to houses 3, 3+4, 3+4+5, ... (3, 7, 12, 18, 25, ...)
- ...
There are infinitely many Elves, numbered starting with 1. Each Elf delivers exactly 1 present at each house.
So, the first nine houses on the street end up like this:
- House 1 gets 1 present (by Elf 1).
- House 2 gets 1 present (by Elf 2).
- House 3 gets 2 presents (by Elves 1 and 3).
- House 4 gets 1 present (by Elf 4).
- House 5 gets 2 presents (by Elves 2 and 5).
- House 6 gets 2 presents (by Elves 1 and 6).
- House 7 gets 2 presents (by Elves 3 and 7).
- House 8 gets 1 present (by Elf 8).
- House 9 gets 3 presents (by Elves 2 (2+3+4), 4 (4+5), and 9).
So the lowest-numbered house that gets at least 3 presents is House 9.
Given a positive number n
, what is the lowest house number that will get at least n
presents?
Standard code-golf rules apply. The shortest code in bytes wins.
Test cases
n -> answer
1 -> 1
2 -> 3
3 -> 9
4 -> 15
5 -> 45
6 -> 45
7 -> 105
8 -> 105
9 -> 225
10 -> 315
12 -> 315
17 -> 1575
25 -> 10395