Solution to problem 13

This commit is contained in:
David Doblas Jiménez 2021-07-22 22:02:56 +02:00
parent 88d72d2a76
commit 70f5057551

32
src/Python/Problem013.py Normal file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env python3
"""
Created on 1 Jan 2018
@author: David Doblas Jiménez
@email: daviddoji@pm.me
Solution for problem 13 of Project Euler
https://projecteuler.net/problem=13
"""
from utils import timeit
@timeit("Problem 13")
def compute():
"""
Work out the first ten digits of the sum of the following one-hundred
50-digit numbers.
"""
with open("files/Problem13.txt", "r") as f:
num = f.readlines()
result = 0
for line in num:
result += int(line)
return str(result)[:10]
if __name__ == "__main__":
print(f"Result for Problem 13: {compute()}")