Skip to content

Instantly share code, notes, and snippets.

@iamjohnnym
Created February 5, 2020 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamjohnnym/939d07a2facab5f470bb23d21a2c90fd to your computer and use it in GitHub Desktop.
Save iamjohnnym/939d07a2facab5f470bb23d21a2c90fd to your computer and use it in GitHub Desktop.
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