require 'set's = [1, 2, 3, -1, -2, -4].to_set# Divide the set into sets of adjacent numbersp s.divide { |x,y| (x-y).abs == 1 }# => #,# => #,# => #}>