return P, N

def subset_sum(seq, s=0):
    P, N = positive_negative_sums(seq)
if not seq or s < N or s > P:
    return False
n, m = len(seq), P - N + 1
table = [([False] * m) for x in range(n)]
table[0][seq[0]] = True
for i in range(1, n):
    for j in range(N, P + 1):
        table[i][j] = seq[i] == j or table[i - 1][j] or table[i - 1][j - seq[i]
            ]
return table[n - 1][s]
Subset sum recursively in Python