Skip to content

Instantly share code, notes, and snippets.

@filipechagas
Created April 23, 2021 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filipechagas/9d7a6119af044b66289a968ad3f8b448 to your computer and use it in GitHub Desktop.
Save filipechagas/9d7a6119af044b66289a968ad3f8b448 to your computer and use it in GitHub Desktop.
Smallets Positive Integer
class Smallest
def self.resolve(array_size, array_of_numbers)
( (1..array_size + 1).to_a - array_of_numbers ).min
end
end
require 'test/unit'
require_relative './smallest'
class SmallestTest < Test::Unit::TestCase
def test_4
assert_equal 4, Smallest.resolve(3, [1, 2, 3])
end
def test_2
assert_equal 2, Smallest.resolve(3, [5, 3, 1])
end
def test_1
assert_equal 1, Smallest.resolve(5, [2, 3, 4, 5, -10])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment