目標番号(レベル2)


1.質問



2.私の回答


from itertools import combinations

def solution(numbers, target):
    answer = 0
    cases = []
    indexes = [i for i in range(0, len(numbers))]
    
    for i in range(0, len(numbers)+1):
        combs = combinations(indexes, i)
        for c in list(combs):
            sum = 0
            for t in indexes:
                if t in c:
                    sum -= numbers[t]
                else:
                    sum += numbers[t]
            if sum == target:
                answer += 1
    
    return answer
組み合わせじゃないと解けない…!

3.他人の回答






4.感じ


鬼を活用した草がたくさん
また家に帰るのに慣れなければなりません.