July 31, 2021
def solution(numbers, target):
parent = [0]
for n in numbers:
child = []
for p in parent:
child.append(p + n)
child.append(p - n)
parent = child
return parent.count(target)
def solution(numbers, target):
if not numbers and target == 0 :
return 1
elif not numbers:
return 0
else:
return solution(numbers[1:], target-numbers[0]) + solution(numbers[1:], target+numbers[0])