Add some utility methods for lists of sets.

This commit is contained in:
Danila Fedorin 2020-12-05 21:48:15 -08:00
parent 48ba4e1577
commit 15f578525d

13
src/advent/util.cr Normal file
View File

@ -0,0 +1,13 @@
class Array(T)
def union
reduce(T.new) do |l, r|
l | r
end
end
def intersect
reduce do |l, r|
l & r
end
end
end