improva part a

This commit is contained in:
2023-12-02 00:23:42 +01:00
parent 3dee74b5e3
commit a131ef4715

View File

@@ -6,8 +6,10 @@ def calibrate(data: list) -> int:
"""
Solve part a.
"""
n = "".join(c for c in data if c.isdigit())
return int(n[0] + n[-1])
# filter digits
digits = [c for c in data if c.isdigit()]
# return the sum of the first and the last digit
return int(digits[0] + digits[-1])
def translate(s: str) -> str: