Sort Integers by the Power Value

A plasma forge processes energy signatures. Each signature is a positive integer, and the forge reduces it to the stable baseline value 1 by repeatedly applying a single transformation: if the current value is even, divide it by 2; if the current value is odd, multiply it by 3 and add 1. One application of the transformation counts as one step.

The transformation cost of a signature is the total number of steps the forge needs to turn that signature into 1.

Given a range of signatures from lo to hi inclusive, line them up in nondecreasing order of transformation cost. When two signatures have the same transformation cost, the smaller signature comes first.

Return the signature that lands at position k in this ordering, where positions are 1-indexed.

Examples
Input: [12,15,2]
Output: 13
Hints

Sort Integers by the Power Value

A plasma forge processes energy signatures. Each signature is a positive integer, and the forge reduces it to the stable baseline value 1 by repeatedly applying a single transformation: if the current value is even, divide it by 2; if the current value is odd, multiply it by 3 and add 1. One application of the transformation counts as one step.