Skip to content

Instantly share code, notes, and snippets.

@claudiokerekes
Created November 2, 2023 15:41
Show Gist options
  • Save claudiokerekes/c528a2ee66263b8159b0023d08199d2f to your computer and use it in GitHub Desktop.
Save claudiokerekes/c528a2ee66263b8159b0023d08199d2f to your computer and use it in GitHub Desktop.
def get_positive(array)
arr = array.uniq.sort
smallest = 1
arr.each do |num|
if num == smallest
smallest += 1
elsif num > smallest
return smallest
end
end
puts "nothing"
end
irb(main):141> get_positive(data2) <= [1,2,3,4,5]
nothing
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment