Few more problems

This commit is contained in:
MitchellHansen
2017-04-23 22:19:11 -07:00
parent 13a163e81d
commit b3831fb360
6 changed files with 172 additions and 7 deletions

29
problem_28.py Normal file
View File

@@ -0,0 +1,29 @@
# What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way?
# top right
tr_sum = 1
for i in range(1, 501):
tr_sum += pow(i * 2 + 1, 2)
# bottom right
br_sum = 1
br_tmp = 1
for i in range(1, 501):
br_tmp += 2 + 8 * (i-1)
br_sum += br_tmp
# bottom left
bl_sum = 1
for i in range(1, 501):
bl_sum += pow(i * 2, 2) + 1
# top left
tl_sum = 1
tl_tmp = 1
for i in range(1, 501):
tl_tmp += (i-1) * 8 + 6
tl_sum += tl_tmp
# I guess the problem is looking to not repeat the center case to take away 3
print(tl_sum + bl_sum + br_sum + tr_sum - 3)