It seems that I can’t make it right and as simple as it was. So I’ll stick with this solution:
def findOutlier numbers if numbers.first(3).count(&:even?) > 1 numbers.find(&:odd?) else numbers.find(&:even?) end end puts findOutlier([2, 4, 0, 100, 4, 11, 2602, 36]) puts findOutlier([160, 3, 1719, 19, 11, 13, -21, 33]) puts findOutlier([160, 3, 1719, 19, 11, 13, -21]) puts findOutlier([4, 8, 15, 16, 24, 42]) puts findOutlier([16, 6, 40, 66, 68, 28]) puts findOutlier([3,3])
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It seems that I can’t make it right and as simple as it was. So I’ll stick with this solution: