Created
March 5, 2015 20:30
-
-
Save calvinfroedge/81df204aeee3fe0f8cc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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