Преглед изворни кода

Get rid of reduce() in 2020 day 6

Taddeus Kroes пре 5 година
родитељ
комит
7f8b3f0600
1 измењених фајлова са 2 додато и 3 уклоњено
  1. 2 3
      2020/06_customs.py

+ 2 - 3
2020/06_customs.py

@@ -1,6 +1,5 @@
 #!/usr/bin/env python3
 import sys
-from functools import reduce
 
 def parse(f):
     cur = []
@@ -13,5 +12,5 @@ def parse(f):
     yield cur
 
 groups = list(parse(sys.stdin))
-print(sum(len(reduce(set.union, map(set, g))) for g in groups))
-print(sum(len(reduce(set.intersection, map(set, g))) for g in groups))
+print(sum(len(set.union(*map(set, g))) for g in groups))
+print(sum(len(set.intersection(*map(set, g))) for g in groups))