Skip to content

Instantly share code, notes, and snippets.

@sbrinkmeyer
Created March 2, 2018 20:24
Show Gist options
  • Save sbrinkmeyer/d5de8cb00bbdcdd190b2645d8bee66a1 to your computer and use it in GitHub Desktop.
Save sbrinkmeyer/d5de8cb00bbdcdd190b2645d8bee66a1 to your computer and use it in GitHub Desktop.
to see if an array has 2 numbers in it that add up to a search number.
numers = [ 2, 5, 8, 9, 13, 6, 22 ]
search_numer = 22
def funcyChicken(numberList=None,searchNumber=None):
retValue=False
temp_list = numberList[:]
for x in range(0,len(numberList)-1):
print numberList[x]
del temp_list[x]
other=search_numer-numberList[x]
if other in temp_list:
retValue=True
break
temp_list = numberList[:]
return retValue
return_value = funcyChicken(numers,search_numer)
print 'did we find the number where 2 numbers in the array added up to this? : {}'.format(return_value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment