@@ -0,0 +1,1387 @@
+# Two versions of working with a list. The first is a nested loop, the second %0D%0A#     uses a dictionary for better access time.%0D%0A%0D%0A%0D%0Adef find_pairs_simple(candidate_array, TARGET_VALUE=10):%0D%0A    for i in range(len(candidate_array)):%0D%0A        for j in range(i + 1, len(candidate_array)):%0D%0A            if (TARGET_VALUE == candidate_array%5Bi%5D + candidate_array%5Bj%5D):%0D%0A                if RUN_STANDALONE:%0D%0A                   print %22%25d,%25d%22 %25 (candidate_array%5Bi%5D, candidate_array%5Bj%5D)%0D%0A               else:%0D%0A                   None%0D%0A%0D%0A    return 0%0D%0A%0D%0A%0D%0A%0D%0Adef find_pairs(candidate_array, TARGET_VALUE=10):%0D%0A    from collections import defaultdict%0D%0A    positions = defaultdict(list)%0D%0A     %0D%0A    #Read everything into a dictionary, storing the original array position %0D%0A    for i in range(len(candidate_array)):%0D%0A        positions%5Bcandidate_array%5Bi%5D%5D.append(i)%0D%0A%0D%0A    #Read list comparing value to TARGET_VALUE %0D%0A    for i in range(len(candidate_array)):%0D%0A        pair_value = TARGET_VALUE - candidate_array%5Bi%5D%0D%0A        if positions%5Bpair_value%5D:%0D%0A            for p in positions%5Bpair_value%5D:%0D%0A                if p %3E i:%0D%0A                    if RUN_STANDALONE:%0D%0A                       print %22%25d,%25d%22 %25 (candidate_array%5Bi%5D, pair_value)%0D%0A                   else:%0D%0A                       None%0D%0A    return 0%0D%0A      %0D%0A    %0D%0A%0D%0Aif %22__main__%22 == __name__:%0D%0A   RUN_STANDALONE = True%0D%0A   test_pairs = %5B :%0D%0A%0D%0A#EOF%0D%0A

Replace doctests with pytest