From f4ef5ba6875cc3a888c39ed5c495cfffc1be13c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Wed, 16 Dec 2020 20:51:47 +0100 Subject: 16: oneline some more --- 20/py/d16.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to '20/py') diff --git a/20/py/d16.py b/20/py/d16.py index 5d03c01..7af1e6a 100644 --- a/20/py/d16.py +++ b/20/py/d16.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import aoc20 import sys +from functools import reduce def pt1(_in): @@ -45,17 +46,15 @@ def pt2(_in): if len(cand) == 1: know[c] = cand.pop() to_remove = know[c] - break for cand in candidates: if to_remove in cand: cand.remove(to_remove) - my = list(int(n) for n in _in[22].strip().split(",")) - res = 1 - for f, field in enumerate(know): - if field < 6: - res *= my[f] - return res + return reduce(lambda x, y: x * y, + (int(_in[22].strip().split(",")[f]) + for f, field in enumerate(know) + if field < 6), + 1) if __name__ == "__main__": -- cgit v1.2.1