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/README | 2 +- 20/py/d16.py | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/20/README b/20/README index 03d5894..4d7a179 100644 --- a/20/README +++ b/20/README @@ -17,7 +17,7 @@ Day Time Ans Time Ans 13 0.006 2095 0.018 598411311431841 14 4.357 15018100062885 55.561 5724245857696 15 0.363 232 10516.154 18929178 - 16 3.340 18227 32.481 2355350878831 + 16 156.622 18227 33.297 2355350878831 ------- ------- tot TBD ms TBD ms 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