Problem 4 in the 2019 BMO, Round 1 describes the following setup:
There are \$2019\$ penguins waddling towards their favourite restaurant. As the penguins arrive, they are handed tickets numbered in ascending order from \$1\$ to \$2019\$, and told to join the queue. The first penguin starts the queue. For each \$n > 1\$ the penguin holding ticket number \$n\$ finds the greatest \$m < n\$ which divides \$n\$ and enters the queue directly behind the penguin holding ticket number \$m\$. This continues until all \$2019\$ penguins are in the queue.
The second part of the question asked candidates to determine the penguins standing directly in front of, and directly behind, penguin \$33\$. This could be done by examining the patterns in the queue, considering prime factors: see the online video solutions for more information.
Your task is to design a program or function which, given a positive integer \$k\$ representing the penguin with ticket number \$k\$, outputs the ticket numbers of the penguins directly before and after this penguin.
For example, penguin \$33\$, stands directly behind \$1760\$ and directly in front of \$99\$, so the program should output, in some reasonable format, \$[1760, 99]\$.
- The input will be an integer in the range \$1 < k \le 2019\$.
- Your program should output two integers, in any reasonable format, representing the ticket numbers of the penguins before and after.
- These can be output in any order, (front first or behind first) but this order must be consistent.
- The penguin will not be at the front or back of the queue: so you don't have to handle the edge cases of \$k = 1\$ or \$k = 1024\$.
- As penguins find it difficult to read human glyphs, your program should be as short as possible. This is a code-golf - so the shortest program (in bytes) wins!
These outputs are given in the format
33 -> [1760, 99] 512 -> [256, 1024] 7 -> [1408, 49] 56 -> [28, 112] 1387 -> [1679, 1241] 2019 -> [673, 1346] 2017 -> [1, 2011] 2 -> [1536, 4]