- Notifications
You must be signed in to change notification settings - Fork 46.7k
/
Copy pathsol1.py
26 lines (19 loc) · 557 Bytes
/
sol1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Problem 13: https://projecteuler.net/problem=13
Problem Statement:
Work out the first ten digits of the sum of the following one-hundred 50-digit
numbers.
"""
importos
defsolution():
"""
Returns the first ten digits of the sum of the array elements
from the file num.txt
>>> solution()
'5537376230'
"""
file_path=os.path.join(os.path.dirname(__file__), "num.txt")
withopen(file_path) asfile_hand:
returnstr(sum(int(line) forlineinfile_hand))[:10]
if__name__=="__main__":
print(solution())