def array_to_ranges(ar)
      prev = ar[0]

      ranges = ar.slice_before do |e|
        prev2 = prev
        prev = e
        prev2 + 1 != e
      end.map { |a| a[0]..a[-1] }

      ranges
    end
def array_to_ranges(ar)
      prev = ar[0]

      ranges = ar.slice_before do |e|
        prev2 = prev
        prev = e
        prev2 + 1 != e
      end.map { |a| a[0]..a[-1] }

      ranges
    end
converts an array of integers into array of ranges