File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
tmu_ctf_too_many_challenge Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 11numbers = []
2+ dictionary = {}
3+
24print ('starting' )
35with open ("numbers.txt" ) as f :
46 content = f .readlines ()
57for n in content :
6- numbers .append (int (n .strip ()))
8+ dictionary [int (n .strip ())] = 0
9+
10+
711print ('numbers are ready' )
812
13+
14+
915def func (x ):
1016 print ('func started for %s' % x )
1117 # Returns the number of distinct pairs (y, z) from the numbers in the file "numbers.txt" whose y != z and (y + z) == x
1218 # Note that two pairs (y, z) and (z, y) are considered the same and are counted only once
1319 ans = set ()
1420 step = 0
15- for i in numbers :
21+ for i in dictionary :
1622 j = x - i # we are looking for j where j+i == x
17- if j in numbers :
23+ if j in dictionary :
1824 if j == i :
1925 continue
2026 elif j > i :
2127 ans .add ((j ,i ))
2228 else :
2329 ans .add ((i ,j ))
30+
31+ print (len (ans ) )
2432 return len (ans )
2533
2634
You can’t perform that action at this time.
0 commit comments