|
| 1 | +numbers = [] |
| 2 | +print ('starting') |
| 3 | +with open("numbers.txt") as f: |
| 4 | + content = f.readlines() |
| 5 | +for n in content: |
| 6 | + numbers.append(int(n.strip())) |
| 7 | +print ('numbers are ready') |
| 8 | + |
| 9 | +def func(x): |
| 10 | + print ('func started for %s' % x) |
| 11 | + # Returns the number of distinct pairs (y, z) from the numbers in the file "numbers.txt" whose y != z and (y + z) == x |
| 12 | + # Note that two pairs (y, z) and (z, y) are considered the same and are counted only once |
| 13 | + ans = set() |
| 14 | + step = 0 |
| 15 | + for i in numbers: |
| 16 | + j = x - i # we are looking for j where j+i == x |
| 17 | + if j in numbers: |
| 18 | + if j == i: |
| 19 | + continue |
| 20 | + elif j > i: |
| 21 | + ans.add((j,i)) |
| 22 | + else: |
| 23 | + ans.add((i,j)) |
| 24 | + return len(ans) |
| 25 | + |
| 26 | + |
| 27 | +def get_flag(res): |
| 28 | + flag = [] |
| 29 | + for i in range(len(res)): |
| 30 | + flag.append(chr(func(res[i]))) |
| 31 | + flag = ''.join(flag) |
| 32 | + return flag |
| 33 | + |
| 34 | + |
| 35 | +if __name__ == "__main__": |
| 36 | + res = [751741232, 519127658, 583555720, 3491231752, 3333111256, 481365731, 982100628, 1001121327, 3520999746, |
| 37 | + 915725624, 3218509573, 3621224627, 3270950626, 3321456817, 3091205444, 999888800, 475855017, 448213157, |
| 38 | + 3222412857, 820711846, 3710211491, 3119823672, 3333211607, 812955676, 971211391, 3210953872, 289789909, |
| 39 | + 781213400, 578265122, 910021887, 653886578, 3712776506, 229812345, 582319118, 1111276998, 1151016390, |
| 40 | + 700123328, 1074521304, 3210438183, 817210125, 501231350, 753244584, 3240911853, 415234677, 469125436, |
| 41 | + 592610671, 612980665, 291821367, 344199617, 1011100412, 681623864, 897219249, 3132267885, 565913000, |
| 42 | + 301203203, 3100544737, 432812663, 1012813485, 510928797, 671553831, 3216409218, 3191288433, 698777123, |
| 43 | + 3512778698, 810476845, 3102989588, 3621432709, 812321695, 526486561, 378912454, 3316207359, 623111580, |
| 44 | + 344209171, 537454826, 691277475, 2634678623, 1112182335, 792111856, 762989676, 666210267, 871278369, |
| 45 | + 581009345, 391231132, 921732469, 717217468, 3101412929, 3101217354, 831912337, 532666530, 701012510, |
| 46 | + 601365919, 492699680, 2843119525] |
| 47 | + print("The flag is", get_flag(res)) |
0 commit comments