# Arup Guha
# 11/5/2020
# Program to calculate # of solutions to a + b + c + d = n, where a is
# forced to be either even or odd.

# Combination function...
def combo(n,k):
    res = 1
    for i in range(k):
        res = res*(n-i)
        res = res//(i+1)
    return res

# I've just solved it up to 10 here, you can change what n is set to.
n = 10

# Storing the lists for the three functions defined in lecture.
odd = [0]
even = [1]
f = [1]

# Build up the answers.
for i in range(1, n+1):

    # We get this from the previous even value.
    odd.append(even[-1])

    # We have a formula from combos with repetition for this one.
    f.append(combo(i+3,3))

    # And we can get this by subtracting.
    even.append(f[-1]-odd[-1])

# Prints out # of odd sols.
print("Num solutions with a odd =",odd[-1])

# Print whole table.
print("n\tOdd\tEven\tTotal")
for i in range(n):
    print(i,odd[i],even[i],f[i],sep="\t")


