Xor Permutation
Chef has received a challenge for which he needs your help. Given $N$, find a *permutation* $P$ of numbers $(1, 2, \ldots, N)$ such that: - $P_i \oplus P_{i+1} \neq P_{i+2} \text{ , where } (1 \leq i \leq N-2)$. Here $\oplus$ denotes the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) operation. If multiple such permutations exist, print any. If no such permutation exists,
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.
Sign in to chat with the tutor and save your progress.
Sign in to start