@@ -0,0 +1,550 @@
+#Author: Maple0%0A#Github:https://github.com/Maple0%0A#8st Sep 2016%0A#Given a sum  and a array, find out the number pairs that has the same sum value%0A#For example, array= %5B-2,0,1,2,4,6,7,8,10%5D sum=8 %0A#expected output %5B-2,10%5D,%5B0,8%5D,%5B1,7%5D%0A%0Adef sum_search(arr,sum):%0A%09num_pairs=%7B%7D%0A%09length=len(arr)%0A%09if len(arr)%3E1:%0A%09%09for i in range(0,length/2):%0A%09%09%09rem=sum-arr%5Bi%5D%0A%09%09%09for j in range(i+1,length):%0A%09%09%09%09if arr%5Bj%5D==rem and num_pairs.has_key(rem)==False:%0A%09%09%09%09%09num_pairs%5Brem%5D=%5Barr%5Bi%5D,arr%5Bj%5D%5D%0A%09return num_pairs%0A%0A%0Aarray= %5B-2,0,1,2,4,6,7,8,10%5D%0Aprint(sum_search(array,8))%0A

add sum-search algorithm