Learned a lot about the Josephus' Problem today!
Solved part 1 by using a dict, but eventually
ended up just adding the mathematical shortcut
and rewriting both parts to use deque() for
performance.
Part 2 was tricky, since k (the elf to remove
after all presents were stolen from them) is a
index that changes over time. No tries for a
solution that was performant enough using lists
and dicts were succesfull, so by inspiration from
the subreddit the final solution code is based on
2 deque() that pops and appends between them.
There are 2 part 1 solutions.
- A correct implementation of the Josephus' Problem,
using deque(). Recursion would have worked as well,
but Python do not like recursions.
- The mathematical superior version, with a link
to the Youtube video were it is introduced.