gets points = gets.split.map(&:to_i).uniq.sort if points.length < 2 puts 0 return end dist = (points[0] - points[1]).abs for i in 0...(points.length - 1) if dist > (points[i] - points[i + 1]).abs dist = (points[i] - points[i + 1]).abs end end puts dist