A bookkeeping system indexes ledger entries starting from 1. An audit tool computes a checksum for any span of entries by XOR-ing together every index from l to r inclusive.
Given l and r, compute this checksum.
Line 1: two space-separated integers l r.
A single integer: the XOR of every integer from l to r inclusive.
Example 1
Input
1 4
Expected
4
Explanation
1 XOR 2 XOR 3 XOR 4 = 4.
Example 2
Input
5 5
Expected
5
Explanation
A single-entry span, so the checksum 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 →