-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathS-MissingInteger.rb
More file actions
65 lines (55 loc) · 1.21 KB
/
S-MissingInteger.rb
File metadata and controls
65 lines (55 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# you can use puts for debugging purposes, e.g.
# puts "this is a debug message"
def solution(a)
hash = {}
a.each { |v|
hash[v] = true
}
i = 1
while true
return i if not hash[i]
i += 1
end
end
require "minitest/autorun"
require "byebug"
require "timeout"
class TestSolution < Minitest::Test
def test_default
input = [1, 3, 6, 4, 1, 2]
output = 5
assert_equal output, solution(input)
end
def test_one
input = [4]
output = 1
assert_equal output, solution(input)
end
def test_one_2
input = [1]
output = 2
assert_equal output, solution(input)
end
def test_one_3
input = [0]
output = 1
assert_equal output, solution(input)
end
def test_negative
input = [-1, -2, -3]
output = 1
assert_equal output, solution(input)
end
# def test_empty
# input = []
# output = 0
# assert_equal output, solution(input)
# end
# def test_large
# input = [0] * 100_000
# output = 0
# Timeout::timeout(6) {
# assert_equal output, solution(input)
# }
# end
end