Convert a non-negative integer to its Gray code equivalent using bitwise XOR and shift.
Constraints
Example
>>> gray_encode(0) 0 >>> gray_encode(1) 1 >>> gray_encode(2) 3 >>> gray_encode(3) 2 >>> gray_encode(4) 6 >>> gray_encode(5) 7
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints