← All problemsSign in

Collatz Conjecture (Hard)

CodeChefRating 2127Open on judge ↗

You are given an integer $N$. You can do the following operations: - If $N$ is even, choose to change $N$ to either $(3 \oplus N) + 1$ or $\dfrac{N}{2}$. - If $N$ is odd, change $N$ to $(3 \oplus N) + 1$. Here, $\oplus$ denotes the Bitwise XOR operator. Check if it is possible to go from $N$ to $1$, and further find the minimum operations to do so. If it is not possible, print $-1$. ### Input

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start