Skip to content

Instantly share code, notes, and snippets.

@Abdujabbar
Created January 29, 2016 06:58
Show Gist options
  • Save Abdujabbar/6d96b74d6f480f6545cc to your computer and use it in GitHub Desktop.
Save Abdujabbar/6d96b74d6f480f6545cc to your computer and use it in GitHub Desktop.
sansa and xor
t = int(input())
for i in range(t):
n = int(input())
a = [int(x) for x in input().split()]
_sum = a[0]
for i in range(1, n):
_sum = _sum ^ a[i]
result = _sum
step = 2
while step < n:
for i in range(n):
if n - i >= step:
__sum = a[i]
for j in range(i + 1, i + step):
if j < n:
__sum = __sum ^ a[j]
_sum = _sum ^ __sum
step += 1
print(_sum ^ result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment