DEV Community

Discussion on: Daily Challenge #35 - Find the Outlier

Collapse
 
hanachin profile image
Seiei Miyagi

ruby 2.7

def findOutlier(a) a.group_by(&:even?).each_value { return @1 if @2.nil? }; nil end
p [
  [2, 4, 0, 100, 4, 11, 2602, 36],
  [160, 3, 1719, 19, 11, 13, -21],
  [4, 8, 15, 16, 24, 42],
  [16, 6, 40, 66, 68, 28]
].map(&self.:findOutlier)

# [11, 160, 15, nil]