Skip to content

Instantly share code, notes, and snippets.

@doubledare704
Created February 28, 2019 11:16
Show Gist options
  • Save doubledare704/8426751ffdd021528cc0a0f6011de928 to your computer and use it in GitHub Desktop.
Save doubledare704/8426751ffdd021528cc0a0f6011de928 to your computer and use it in GitHub Desktop.
Find a pair of two created by doubledare704 - https://repl.it/@doubledare704/Find-a-pair-of-two
def magic_sum_of_two(number_list, magic_number):
print("We should find pair of numbers to sum a magic one")
print("For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.")
print(f"Number list: {number_list}")
print(f"Magic number: {magic_number}")
for idx, val in enumerate(number_list):
temp_n = magic_number - val
if temp_n in number_list:
print(f"The answer is {temp_n} {val}")
randoms = [3, 7, 9 , 14, 2, 5, 7, 1, 8, 11, 12, 13, 14, 15]
magic = 24
magic_sum_of_two(randoms, magic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment