I like problems like this. I like them because the math behind them isn’t initially clear and I get to think creatively about the solution.
bound = 50
count = 0
redDict = dict()
greenDict = dict()
blueDict = dict()
red = 2
green = 3
blue = 4
for k in xrange(bound+1):
redDict[k] = 0
greenDict[k] = 0
blueDict[k] = 0
#red
for length in range(red, bound+1):
for start in range(1, length-red+2):
redDict[length] += 1
redDict[length] += redDict[length-start-red+1]
#green
for length in range(green, bound+1):
for start in range(1, length-green+2):
greenDict[length] += 1
greenDict[length] += greenDict[length-start-green+1]
#red
for length in range(blue, bound+1):
for start in range(1, length-blue+2):
blueDict[length] += 1
blueDict[length] += blueDict[length-start-blue+1]
count = redDict[bound] + greenDict[bound] + blueDict[bound]
print count