Skip to content

Instantly share code, notes, and snippets.

@voith
Created November 28, 2019 02:42
Show Gist options
  • Save voith/61a567ce2a64c375abe0c0b4e2611170 to your computer and use it in GitHub Desktop.
Save voith/61a567ce2a64c375abe0c0b4e2611170 to your computer and use it in GitHub Desktop.
sum of the numbers on the diagonals in a 1001 by 1001 spiral
grid_size = 1001
num = grid_size ** 2
sum_diagonals = num
for i in range(grid_size - 1, 0, -2):
for _ in range(4):
num -= i
sum_diagonals += num
print(sum_diagonals)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment