diff options
Diffstat (limited to '20')
| -rw-r--r-- | 20/README | 2 | ||||
| -rw-r--r-- | 20/py/d16.py | 13 |
2 files changed, 7 insertions, 8 deletions
@@ -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__": |
