diff --git a/1/trebuchet.py b/1/trebuchet.py index 9d5db6d..1012870 100644 --- a/1/trebuchet.py +++ b/1/trebuchet.py @@ -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: