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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
require 'test/unit'
class MatchesTest < Test::Unit::TestCase
def test_should_have_no_matches
assert_equal 0, matches(12345678, 10)
end
def test_should_have_one_match_in_same_positiion
assert_equal 1, matches(12341678, 10)
end
def test_should_have_one_match_in_different_positiion
assert_equal 1, matches(12345671, 10)
end
def test_should_have_two_matches_in_same_positiion
assert_equal 2, matches(12341278, 10)
end
def test_should_have_two_duplicate_matches_in_same_positiion
assert_equal 2, matches(11341178, 10)
end
def test_should_have_two_matches_in_different_positiion
assert_equal 2, matches(12345621, 10)
end
def test_should_have_two_duplicate_matches_in_different_positiion
assert_equal 2, matches(11345611, 10)
end
def test_should_have_three_matches_in_same_positiion
assert_equal 3, matches(12341238, 10)
end
def test_should_have_three_duplicate_matches_in_same_positiion
assert_equal 3, matches(11141118, 10)
end
def test_should_have_three_matches_in_different_positiion
assert_equal 3, matches(12345321, 10)
end
def test_should_have_three_duplicate_matches_in_different_positiion
assert_equal 3, matches(11145111, 10)
end
def test_should_have_four_matches_in_same_position
assert_equal 4, matches(12341234, 10)
end
def test_should_have_four_duplicate_matches
assert_equal 4, matches(11111111, 10)
end
def test_should_have_four_matches_in_different_position
assert_equal 4, matches(12344321, 10)
end
def test_should_have_one_match_when_digit_appears_twice_on_lhs_but_once_on_rhs
assert_equal 1, matches(11345178, 10)
end
def test_should_have_one_match_when_digit_appears_once_on_lhs_but_twice_on_rhs
assert_equal 1, matches(12345118, 10)
end
def test_should_have_two_matches_when_digit_appears_three_times_on_lhs_but_twice_on_rhs
assert_equal 2, matches(11145118, 10)
end
def test_should_have_two_matches_when_digit_appears_twice_on_lhs_but_three_times_on_rhs
assert_equal 2, matches(12315111, 10)
end
def test_should_have_three_matches_when_digit_appears_four_times_on_lhs_but_three_times_on_rhs
assert_equal 3, matches(11115111, 10)
end
def test_should_have_three_matches_when_digit_appears_three_times_on_lhs_but_four_times_on_rhs
assert_equal 3, matches(11141111, 10)
end
end
|