Solve problem 347 and some reformatting.
This commit is contained in:
@@ -2,13 +2,14 @@ import math
|
||||
|
||||
|
||||
def is_square(apositiveint):
|
||||
""" From: https://stackoverflow.com/a/2489519 """
|
||||
"""From: https://stackoverflow.com/a/2489519"""
|
||||
x = apositiveint // 2
|
||||
seen = set([x])
|
||||
while x * x != apositiveint:
|
||||
x = (x + (apositiveint // x)) // 2
|
||||
if x in seen: return False
|
||||
seen.add(x)
|
||||
x = (x + (apositiveint // x)) // 2
|
||||
if x in seen:
|
||||
return False
|
||||
seen.add(x)
|
||||
return True
|
||||
|
||||
|
||||
@@ -16,7 +17,7 @@ def canditates(current_value, depth):
|
||||
if depth <= 0:
|
||||
yield current_value
|
||||
else:
|
||||
d = 10 ** depth
|
||||
d = 10**depth
|
||||
for i in range(10):
|
||||
for new_value in canditates(current_value - i * d, depth - 2):
|
||||
yield new_value
|
||||
@@ -32,5 +33,4 @@ def euler_206():
|
||||
if __name__ == "__main__":
|
||||
solution = euler_206()
|
||||
print("e206.py: " + str(solution))
|
||||
assert(solution == 1389019170)
|
||||
|
||||
assert solution == 1389019170
|
||||
|
||||
Reference in New Issue
Block a user