Problem 115

completed January 24, 2012

Comments

This one was almost the same as problem 114. I don’t know why I then decided to rewrite the whole thing. I tried to rewrite it three times, but once I finally just copied and pasted the code from the previous problem, that’s when it started to work.

Code

def F(m, n):
	colorDict = dict()

	for k in xrange(-1, n+1):
		colorDict[k] = 0

	for length in range(m, n+1):
		for start in range(1, length):
			for end in range(m, n+1):
				if start + end - 1 > length: continue
				colorDict[length] += 1
				colorDict[length] += colorDict[length-(start+end)]
	
	return colorDict[n] + 1


n = 50
while True:
	if F(50, n) > 10**6:
		print n
		break
	else:
		n += 1