Company: Purplle Engineering intern_24may
Difficulty: medium
K-Step Bit Decryption You are part of the Cyber Security team in your company, working on a decryption algorithm that transforms a number into the count of set bits (1s) in its binary representation. This process can be repeated: each time, the number is replaced by the number of set bits in its binary form. Formally the decryption step is \(f(x) = \operatorname{popcount}(x)\). A positive integer \(x\) is a possible decryption for K when the number of steps needed to turn \(x\) into 1 is exactly K — that is, applying \(f\) repeatedly to \(x\) first reaches the value 1 after precisely \(K\) steps. Because 1 is already 1, the number 1 needs 0 steps; it is a possible decryption for \(K = 0\) only, never for \(K \ge 1\). For example, applying the algorithm once to 12 (binary 1100 ) gives 2, because 12 has two set bits. Applying it again to 2 (binary 10 ) gives 1. So 12 reaches 1 after exactly 2 steps and is a possible decryption for \(K = 2\), and for no other \(K\). You are given a binary