diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2020-12-16 19:13:48 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2020-12-16 19:13:48 +0100 |
| commit | d93f49922095c1bf9165523d4e86bffba94459ad (patch) | |
| tree | 8d17325931e5cddd2c63dddc11b526735f2499fb /20 | |
| parent | 1707bb001f24330dbe67b11e6ed665ad5054745d (diff) | |
| download | aoc-d93f49922095c1bf9165523d4e86bffba94459ad.tar.gz | |
16: part 1 actually one line
Diffstat (limited to '20')
| -rw-r--r-- | 20/py/d16.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/20/py/d16.py b/20/py/d16.py index 09a7c9c..5d03c01 100644 --- a/20/py/d16.py +++ b/20/py/d16.py @@ -4,14 +4,15 @@ import sys def pt1(_in): - constraints = [[range(int((b := a.split("-"))[0]), int(b[1])+1) - for a in line.split(": ")[1].split(" or ")] - for line in _in[:20]] return sum(sum(int(field) for field in line.strip().split(",") if not any(any(int(field) in cons for cons in constraint) - for constraint in constraints)) + for constraint in [[range(int(a.split("-")[0]), + int(a.split("-")[1])+1) + for a in line.split(": ")[1] + .split(" or ")] + for line in _in[:20]])) for line in _in[25:]) |
