A tape drive writes a running parity checksum by XOR-ing together every block index in a contiguous span. Given the span endpoints L and R, compute the bitwise XOR of all integers from L to R inclusive.
Line 1: two space-separated integers L and R.
A single integer: L xor (L+1) xor ... xor R.
Example 1
Input
1 4
Expected
4
Explanation
1^2 = 3, 3^3 = 0, 0^4 = 4, so the result is 4.
Example 2
Input
5 5
Expected
5
Explanation
A single element, so the XOR is just 5.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →