Created
June 7, 2016 16:47
-
-
Save wangyiyang/49dfa2806f90ed9eb366fc5b2fca15ed to your computer and use it in GitHub Desktop.
多个数组给定数找出多个数之和等于定数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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