Created
February 5, 2020 23:44
-
-
Save iamjohnnym/939d07a2facab5f470bb23d21a2c90fd 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 split_numbers(numbers): | |
split_size = int(len(numbers) / 2) | |
list_a = numbers[:split_size] | |
list_b = numbers[split_size:] | |
return list_a, list_b | |
def find_matching_sum(match, numbers): | |
list_a, list_b = split_numbers(numbers) | |
for x in list_a: | |
for y in list_b: | |
t = sum([x, y]) | |
if t == match: | |
return x, y | |
if __name__ == '__main__': | |
match = 17 | |
numbers = [10, 15, 3, 7] | |
x, y = find_matching_sum(match, numbers) | |
if x and y: | |
print('Match Found: ', x ,',', y, ' equal ', match) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment