Skip to content

Instantly share code, notes, and snippets.

@kikers25
Created February 27, 2017 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikers25/6b475c6b51c0e767ded0e8f41afaf1ce to your computer and use it in GitHub Desktop.
Save kikers25/6b475c6b51c0e767ded0e8f41afaf1ce to your computer and use it in GitHub Desktop.
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