require 'set's = %w[ant ape cow hen hog].to_set # A set of wordst = s.divide {|x,y| x[0] == y[0]} # Divide it into subsetst.flatten! # Flatten the subsetst == s # => true