Problem 117

completed January 24, 2012

Comments

This was a harder version of problem 116. I basically used the same code, but updated it by adding the “end” variable which gave all options for block lengths as well. Took just .13 seconds to run.

Code

bound = 50
count = 0

colorDict = dict()

for k in xrange(bound+1):
	colorDict[k] = 0

for length in range(2, bound+1):
	for start in range(1, length):
		for end in range(2, 5):
			if start + end - 1 > length: continue
			colorDict[length] += 1
			colorDict[length] += colorDict[length-(start+end)+1]

count = colorDict[bound] + 1
print count