diff --git a/06/06_minimal.py b/06/06_minimal.py index 996ff90..88277d1 100644 --- a/06/06_minimal.py +++ b/06/06_minimal.py @@ -1,8 +1,5 @@ with open("input.txt","r") as f: groups = f.read().split('\n\n') -print( - ( - sum(len(set.union(*map(set, group.splitlines()))) for group in groups), # you can just call set() directly on string, no need to call list() - sum(len(set.intersection(*map(set, group.splitlines()))) for group in groups) - ) -) \ No newline at end of file +sets = [list(map(set, group.split('\n'))) for group in groups] +reduce = lambda fn: sum(len(fn(*s)) for s in sets) +print(reduce(set.union), reduce(set.intersection)) \ No newline at end of file