Skip to content

Instantly share code, notes, and snippets.

@wangyiyang
Created June 7, 2016 16:47
Show Gist options
  • Save wangyiyang/49dfa2806f90ed9eb366fc5b2fca15ed to your computer and use it in GitHub Desktop.
Save wangyiyang/49dfa2806f90ed9eb366fc5b2fca15ed to your computer and use it in GitHub Desktop.
多个数组给定数找出多个数之和等于定数
def getresult(a=None, b=None, c=None, target=None):
for aitem in a:
for bitem in b:
if target - aitem - bitem in c:
return a.index(aitem), bitem, target - aitem - bitem
else:
return None
a = [1, 2, 3]
b = [1, 2, 3]
c = [1, 2, 3]
print getresult(a, b, c, 9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment