Problem 28

completed December 5, 2011

Comments

This one was fun and easy. I found a simple pattern in the numbers that are generated with this method. There was really no need to create the whole square.

I’ve now progressed to Level 1! I’m very excited! I’m currently one of just 35721 people to make it this far. There’s a long road ahead, but I’m still super excited about it.

Code

bound = 1001

diagonals = [1]
for r in range(1, ((bound-1)/2)+1):
	adder =  2 * r
	for c in range(1, 5):
		next = max(diagonals) + adder
		diagonals.append(next)
		if next == (bound**2): break; break
		
print sum(diagonals)