Skip to content

Instantly share code, notes, and snippets.

@peterldowns
Created May 13, 2012 20:46
Show Gist options
  • Save peterldowns/2690104 to your computer and use it in GitHub Desktop.
Save peterldowns/2690104 to your computer and use it in GitHub Desktop.
Project Euler Problem #28
spiral_side = 1001
num_corners = spiral_side/2
total = 1
corners = (1, 1, 1, 1)
additions = (2, 4, 6, 8)
for i in xrange(num_corners):
corners = map(sum, zip(corners, additions))
additions = map(lambda x: x+8, additions)
total += sum(corners)
print total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment