x becomes 3x + 1. The **path length** of a number is how many such steps it takes to reach 1 (1 itself has path length 0). For example, 6 goes 6 → 3 → 10 → 5 → 16 → 8 → 4 → 2 → 1, which is 8 steps.
You are given low, high and place. Write down every integer from low to high inclusive and order them by path length, shortest first; when two numbers have the same path length, the smaller one comes first. Return the number that ends up at position place (counting from 1).
Every number in the range is guaranteed to reach 1.low=6, high=9, place=1 → 8
Steps: 6 takes 8, 7 takes 16, 8 takes 3, 9 takes 19. By steps: 8, 6, 7, 9. First place goes to 8.
low=6, high=9, place=3 → 7
In the same order 8, 6, 7, 9, the third one is 7.
low=1, high=4, place=2 → 2
1 takes 0 steps, 2 takes 1, 4 takes 2 and 3 takes 7 (3 → 10 → 5 → 16 → 8 → 4 → 2 → 1). The order is 1, 2, 4, 3, so second place is 2.
low=6, high=9, place=1
8
Run checks the first 3 tests in your browser. Submit checks all 96 tests on the server, hidden ones included.