Adopted new convention from template
This commit is contained in:
parent
273aeea7f8
commit
8c0f18bc5f
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
Created on 3 Jan 2020
|
Created on 3 Jan 2020
|
||||||
|
|
||||||
@ -29,20 +29,20 @@ def compute():
|
|||||||
What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral
|
What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral
|
||||||
formed in the same way?
|
formed in the same way?
|
||||||
"""
|
"""
|
||||||
|
|
||||||
size = 1001 # Must be odd
|
size = 1001 # Must be odd
|
||||||
ans = 1 # Special case for size 1
|
ans = 1 # Special case for size 1
|
||||||
step = 0
|
step = 0
|
||||||
i, cur = 1, 1
|
i, current = 1, 1
|
||||||
while step < size-1:
|
while step < size - 1:
|
||||||
step = i * 2
|
step = i * 2
|
||||||
for j in range(1, 5):
|
for _ in range(1, 5):
|
||||||
cur += step
|
current += step
|
||||||
ans += cur
|
ans += current
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
print(f"Result for Problem 28 is {compute()}")
|
||||||
print(f"Result for Problem 28: {compute()}")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user