Skip to content

Instantly share code, notes, and snippets.

@kurianbenoy
Created April 27, 2020 17:46
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 kurianbenoy/4659e765cca1144065b2462b9a4c9edf to your computer and use it in GitHub Desktop.
Save kurianbenoy/4659e765cca1144065b2462b9a4c9edf to your computer and use it in GitHub Desktop.
M1 = []
M2 = []
def find_pairs(M1, M2, val):
s =set()
for i in range(0,1000000):
s.add(M1[i])
for j in range(0,1000000):
if((val-M1[j]) in s):
print((val-M1[j]),M1[j])
with open('million2.txt') as f:
for line in f:
line = line.strip()
M1.append(int(line))
with open('millionnumber.txt') as f:
for line in f:
line = line.strip()
M2.append(int(line))
print(len(M1), len(M2))
#if __name__ == "__main__":
find_pairs(M1, M2,val=1000000)
@pythonhacker
Copy link

Initial observations.

  • Creating the files could have been a function - then called with file names as argument
  • Using globals is not a great idea

Detailed comments tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment