diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2020-12-16 20:51:47 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2020-12-16 20:51:47 +0100 |
| commit | f4ef5ba6875cc3a888c39ed5c495cfffc1be13c8 (patch) | |
| tree | c84a7908a31729688d7b8792d595e729a11eec2b /20/py/d16.py | |
| parent | d93f49922095c1bf9165523d4e86bffba94459ad (diff) | |
| download | aoc-f4ef5ba6875cc3a888c39ed5c495cfffc1be13c8.tar.gz | |
16: oneline some more
Diffstat (limited to '20/py/d16.py')
| -rw-r--r-- | 20/py/d16.py | 13 |
1 files changed, 6 insertions, 7 deletions
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__": |
