2023: d01: ex1: add solution
This commit is contained in:
parent
8d8f2b1fb1
commit
771b7f7d25
20
2023/d01/ex1/ex1.py
Executable file
20
2023/d01/ex1/ex1.py
Executable 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()
|
Loading…
Reference in a new issue