Talk:Weird numbers: Difference between revisions

Content added Content deleted
Line 25: Line 25:
def anySum(n, xs):
def anySum(n, xs):
'''First subset of xs found to sum to n.
'''First subset of xs found to sum to n.
(Probably more efficient where the xs are sorted in descending
(Probably more efficient where xs is sorted in descending
order of magnitude)'''
order of magnitude)'''
def go(n, xs):
def go(n, xs):
Line 46: Line 46:


print(anySum(7, [1,1,1,1,1,6]))
print(anySum(7, [1,1,1,1,1,6]))
# -> [1, 6]</lang>
# -> [1, 6]
print(anySum(7, [6, 3]))
# -> []</lang>