Adopted new convention from template
This commit is contained in:
parent
48bd3200b0
commit
1b4f2f2fa6
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
Created on 05 Jun 2021
|
Created on 05 Jun 2021
|
||||||
|
|
||||||
@ -22,16 +22,17 @@ def compute():
|
|||||||
|
|
||||||
For which value of p ≤ 1000, is the number of solutions maximised?
|
For which value of p ≤ 1000, is the number of solutions maximised?
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ans, val = 0, 0
|
ans, val = 0, 0
|
||||||
for p in range(2, 1001, 2):
|
for p in range(2, 1001, 2):
|
||||||
sol = 0
|
sol = 0
|
||||||
for a in range(1, p):
|
for a in range(1, p):
|
||||||
for b in range(a+1, p-2*a):
|
for b in range(a + 1, p - 2 * a):
|
||||||
c = p - (a + b)
|
c = p - (a + b)
|
||||||
if a**2 + b**2 == c**2:
|
if a**2 + b**2 == c**2:
|
||||||
sol += 1
|
sol += 1
|
||||||
elif a**2 + b**2 > c**2:
|
elif a**2 + b**2 > c**2:
|
||||||
# As we continue our innermost loop, the left side
|
# As we continue our innermost loop, the left side
|
||||||
# gets bigger, right gets smaller, so we're done here
|
# gets bigger, right gets smaller, so we're done here
|
||||||
break
|
break
|
||||||
if sol > ans:
|
if sol > ans:
|
||||||
@ -39,6 +40,6 @@ def compute():
|
|||||||
|
|
||||||
return val
|
return val
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
print(f"Result for Problem 39: {compute()}")
|
if __name__ == "__main__":
|
||||||
|
print(f"Result for Problem 39 is {compute()}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user