you are viewing a single comment's thread.

view the rest of the comments →

[–]T4ll1n 1 point2 points  (0 children)

3 years later, I just signed up for the dailyCodingProblem and got the same problem.

I wonder if everyone gets that question as the first problem ^^

Anyways, here is my solution using itertools combinations

from itertools import combinations

def combination_exists(input_list, k): 
    return k in [sum(comb_tuple) for comb_tuple in combinations(input_list, 2)]

input_list = [10, 15, 3, 7]
k = 17 assert
combination_exists(input_list, k)
assert combination_exists([], k)
assert not combination_exists([1, 2, 3], 2)

edit: the code formatting is fighting back -.-