mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-24 05:21:09 +00:00
501a2ff430
* Fix code style for Project Euler problems: - 13, 17, 21 - Default args - Type hints - File path * Fix code style for multiple problems * Made suggested changes
26 lines
563 B
Python
26 lines
563 B
Python
"""
|
|
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.
|
|
"""
|
|
import os
|
|
|
|
|
|
def solution():
|
|
"""
|
|
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")
|
|
with open(file_path, "r") as file_hand:
|
|
return str(sum([int(line) for line in file_hand]))[:10]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(solution())
|