Files
project-euler/src/Python/Problems001-050/Problem013.py

35 lines
668 B
Python

#!/usr/bin/env python
"""
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 pathlib import Path
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.
"""
_file = Path("../files/Problem13.txt")
with open(_file, "r") as f:
num = f.readlines()
ans = 0
for line in num:
ans += int(line)
return str(ans)[:10]
if __name__ == "__main__":
print(f"Result for Problem 13 is {compute()}")