Submit solution

Points:
7

Time limit:
1.0s

Memory limit:
64M

Problem type

Allowed languages

Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, ~~CommonLisp~~, D, Dart, F#, Forth, Fortran, Go, ~~Groovy~~, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, ~~Nim~~, ~~ObjC~~, OCaml, ~~Octave~~, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Given two integers and , what is the XOR (exclusive-or) of all numbers between and (inclusive)?

#### Input Specification

The first line of input is the integer , which is the number of test cases .

lines follow, with each line containing two integers and .

#### Output Specification

For each test case, output the (decimal) value of the XOR of all numbers between and , inclusive.

#### Sample Input

```
5
3 10
5 5
13 42
666 1337
1234567 89101112
```

#### Output for Sample Input

```
8
5
39
0
89998783
```

## Comments

My wrong submission passed. Doesn't even pass sample, more test cases are probably needed.

I'm a bit confused, how is the XOR of 5 and 5 equal to 5? I thought it was 0.

It's asking you for the XOR of all numbers in the range . is the only number in the range , so the answer is 5.

This comment is hidden due to too much negative feedback. Click here to view it.

Look for a pattern!

So there IS a pattern! ahh.....

How do you get an XOR of a multi digit number? Isn't it only for True and False?

We are looking for the bitwise XOR.

When I do that, 3 and 10 give me 9, and 5 and 5 give 0...

you are misunderstanding the problem it asks for the xor of all numbers between s and f, so for the example of 3 and 10 it would be 3 XOR 4 XOR... XOR 10

thanks