Create a gist now

Instantly share code, notes, and snippets.

@kikers25 /storecredit.py Secret
Created Feb 27, 2017

What would you like to do?
Store Credit
def addingCase(n):
return "Case #" + str(n) + ": "
inFile = open("A-large-practice.in", "r")
outFile = open("A-large-practice.out", "w")
n = int(inFile.readline())
print "n is ", n
icase = 1
while icase <= n:
credit = int(inFile.readline())
nElements = int(inFile.readline())
products = [int(x) for x in inFile.readline().split()]
found = False
for x in range(0, nElements):
for y in range(x + 1, nElements):
if (not found):
if (products[x] + products[y] == credit):
result = addingCase(icase) + str(x + 1) + " " + str(y + 1)
print result
outFile.write(result + "\n")
found = True
icase = icase + 1
outFile.close()
inFile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment