MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_013/sol1.py:12–22  ·  view source on GitHub ↗

Returns the first ten digits of the sum of the array elements from the file num.txt >>> solution() '5537376230'

()

Source from the content-addressed store, hash-verified

10
11
12def solution():
13 """
14 Returns the first ten digits of the sum of the array elements
15 from the file num.txt
16
17 >>> solution()
18 '5537376230'
19 """
20 file_path = os.path.join(os.path.dirname(__file__), "num.txt")
21 with open(file_path) as file_hand:
22 return str(sum(int(line) for line in file_hand))[:10]
23
24
25if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected