mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 17:20:16 +00:00
bc8df6de31
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2) - [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.9.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
27 lines
557 B
Python
27 lines
557 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) as file_hand:
|
|
return str(sum(int(line) for line in file_hand))[:10]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print(solution())
|