Solve problem 80 in Python with cheating.

This commit is contained in:
2019-08-31 01:22:15 -04:00
parent 5fc0e4324f
commit 80193ea75b
4 changed files with 254 additions and 2 deletions

View File

@@ -1,8 +1,20 @@
from decimal import *
def euler_080():
return 0
# XXX: totally cheated by using decimal library.
def strsum(s):
return sum(map(int, s))
getcontext().prec = 200
r = 0
for n in range(1, 101):
b = str(Decimal(n).sqrt()).replace(".", "")[:100]
if len(b) == 100:
r += strsum(b)
return r
if __name__ == "__main__":
print("e080.py: " + str(euler_080()))
assert(euler_080() == 0)
assert(euler_080() == 40886)