From c78f8ebf61471a9f4a2228595ef612fb3d10e08e Mon Sep 17 00:00:00 2001 From: setop Date: Mon, 4 Dec 2023 16:13:55 +0100 Subject: [PATCH] day 1 refactor --- d01/run.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/d01/run.py b/d01/run.py index 63a0022..b1fc451 100644 --- a/d01/run.py +++ b/d01/run.py @@ -4,19 +4,13 @@ D = [str(i) for i in range(1,10)] if sys.argv[1] == "2": D += ['one','two','three','four','five','six','seven','eight','nine'] -def process_line(l): +def process(l): k = list() - p = 0 - while (p0 else 0 + return k[0]*10 + k[-1] if len(k)>0 else 0 -R=0 -for l in sys.stdin.readlines(): - n = process_line(l[:-1]) - R+=n[1] -print(R) \ No newline at end of file +print(sum(process(l) for l in sys.stdin.read().splitlines()))