Skip to content

Instantly share code, notes, and snippets.

@calvinfroedge
Created March 5, 2015 20:30
Show Gist options
  • Save calvinfroedge/81df204aeee3fe0f8cc8 to your computer and use it in GitHub Desktop.
Save calvinfroedge/81df204aeee3fe0f8cc8 to your computer and use it in GitHub Desktop.
import sys
lines = open(sys.argv[1], 'r')
for line in lines:
line = line.replace("\n", "").split(";")
arr = line[0].split(",")
n = int(line[1]);
hsh = {}
output = ""
for x in arr:
t = int(x)
if str((n-t)) in arr and t is not (n-t):
m = min(t, n-t)
s = str(m) + "," + str(n-m)
try:
hsh[s]
except:
hsh[s] = True
output = output + ";" + s
print output[1:] or 'NULL'
lines.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment