Created
April 23, 2021 17:48
-
-
Save filipechagas/9d7a6119af044b66289a968ad3f8b448 to your computer and use it in GitHub Desktop.
Smallets Positive Integer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Smallest | |
def self.resolve(array_size, array_of_numbers) | |
( (1..array_size + 1).to_a - array_of_numbers ).min | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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