Skip to content

Instantly share code, notes, and snippets.

@duke79
Created May 13, 2018 09:44
Show Gist options
  • Save duke79/6ad49fac2c2a9bd960b95a8fa675ebe8 to your computer and use it in GitHub Desktop.
Save duke79/6ad49fac2c2a9bd960b95a8fa675ebe8 to your computer and use it in GitHub Desktop.
CodeChef - Python
def mainFile():
f = open("CodeChefInput.txt", "r")
f.readline()
def nextLine():
line = f.readline()
elems = line.split()
if len(elems) < 2:
return int(line)
else:
for idx in range(len(elems)):
elems[idx] = int(elems[idx])
return elems
T = nextLine()
for i in range(T):
N = nextLine()
A = nextLine()
startProblem(A)
def RD19(A):
A.sort()
diff = -1
for k in range(1, len(A)):
if (A[k] - A[k - 1] < diff or diff == -1):
diff = A[k] - A[k - 1]
if diff > 1:
print(-1)
else:
print(0)
def XORAGN(A):
res = 0
for a in A:
for b in A:
res = res ^ (a+b)
print(res)
def startProblem(A):
XORAGN(A)
def mainStdin():
def nextLine():
line = input("")
elems = line.split()
if len(elems) < 2:
return int(line)
else:
for idx in range(len(elems)):
elems[idx] = int(elems[idx])
return elems
T = nextLine()
for i in range(T):
N = nextLine()
A = nextLine()
startProblem(A)
# mainStdin()
mainFile()
5
3
1 2 4
3
2 6 20
3
5 10 11
3
3 7 11
3
3 8 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment