Returns the first ten digits of the sum of the array elements from the file num.txt >>> solution() '5537376230'
()
| 10 | |
| 11 | |
| 12 | def 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 | |
| 25 | if __name__ == "__main__": |