Skip to content

Instantly share code, notes, and snippets.

@andreytwostep
Created September 25, 2017 05:40
Show Gist options
  • Save andreytwostep/7eedb94b5656dbafa4a3c6009308d2c7 to your computer and use it in GitHub Desktop.
Save andreytwostep/7eedb94b5656dbafa4a3c6009308d2c7 to your computer and use it in GitHub Desktop.
import time
f = open('./integers/1000.txt', 'r')
x = map(int, f.read().splitlines())
def solution(nums):
n = len(nums)
res = 0
for i in range(n):
for j in range(i + 1, n):
if nums[i] + nums[j] == 0:
res += 1
return res
start = time.time()
result = solution(x)
time = (time.time() - start);
# 1k | 253 | 0.049782037735
# 2k | 969 | 0.189519166946
# 4k | 4007 | 0.749423980713
# 8k | 16204 | 3.02656292915
# 16k | 63842 | 12.532490015
# 32k | 256505 | 50.928894043
# 64k | ~256505*4 | ~203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment