As reported: Arista Networks software engineer round 1 (virtual, 2026): full, runnable code in an IDE, any language, explaining each line.
Given an unsigned 32-bit number, swap each even nibble with the next odd nibble — that is, swap the two 4-bit halves of every byte.
Reading the hex digits 1 2 3 4 5 6 7 8 as nibbles, the result is 2 1 4 3 6 5 8 7.
Example 1
n = 0x12345678 (305419896) -> 0x21436587 (558065031)
Example 2
n = 0xA5 (165) -> 0x5A (90)
Constraints: 0 ≤ n < 2^32.
Code runner format: one line holding n as a decimal integer. Implement swapNibbles(n); the harness prints the result as a decimal integer.