From: brabuhr@... Date: 2009-11-24T07:25:57+09:00 Subject: Re: Distinct Sets (#225) Here's my not-fast solution: require 'set' class Set def intersect?(other) other.each { |o| return true if include?(o) } false end end def distinct_sets(array_of_arrays) set_of_sets = array_of_arrays.map{|a| a.to_set }.to_set set_of_sets.divide{|i, j| i.intersect?(j) }.map{|s| s.flatten.to_a } end Adding the intersect? method to Set was primarily motivated by readability, but also provided a noticeable speed improvement over my original alternative (intersection.size.>).