2023: d01: ex1: add solution

This commit is contained in:
Bruno BELANYI 2023-12-01 12:13:28 +00:00
parent 1039b4c0ac
commit 447467ef6e

20
2023/d01/ex1/ex1.py Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env python
import sys
def solve(input: list[str]) -> int:
def value(line: str) -> int:
digits = [int(c) for c in line if c.isdigit()]
return digits[0] * 10 + digits[-1]
return sum(value(line) for line in input)
def main() -> None:
input = sys.stdin.read().splitlines()
print(solve(input))
if __name__ == "__main__":
main()