DEV Community

Discussion on: Daily Challenge #278 - Find all non-consecutive numbers

Collapse
 
n8chz profile image
Lorraine Lee

Ruby

def nonconsecutive(a)
  a.each_with_index.drop(1).to_h.invert.select{|k, v| v-a[k-1] != 1}
end