|
|
|
|
|
|
30
|
|
30
|
|
|
31
|
@Test
|
31
|
@Test
|
|
32
|
public void smallestPalindromeFromSingleDigitFactors() {
|
32
|
public void smallestPalindromeFromSingleDigitFactors() {
|
|
33
|
- final List<List<Integer>> expected = Collections.unmodifiableList(
|
|
|
|
|
|
33
|
+ List<List<Integer>> expected = Collections.unmodifiableList(
|
|
34
|
Arrays.asList(
|
34
|
Arrays.asList(
|
|
35
|
Arrays.asList(1, 1)
|
35
|
Arrays.asList(1, 1)
|
|
36
|
)
|
36
|
)
|
|
37
|
);
|
37
|
);
|
|
38
|
- final long expectedValue = 1l;
|
|
|
|
|
|
38
|
+ long expectedValue = 1l;
|
|
39
|
|
39
|
|
|
40
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1, 9);
|
|
|
|
|
|
40
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1, 9);
|
|
41
|
|
41
|
|
|
42
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
|
42
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
|
|
43
|
}
|
43
|
}
|
|
|
|
|
|
|
45
|
@Ignore("Remove to run test")
|
45
|
@Ignore("Remove to run test")
|
|
46
|
@Test
|
46
|
@Test
|
|
47
|
public void largestPalindromeFromSingleDigitFactors() {
|
47
|
public void largestPalindromeFromSingleDigitFactors() {
|
|
48
|
- final List<List<Integer>> expected = Collections.unmodifiableList(
|
|
|
|
|
|
48
|
+ List<List<Integer>> expected = Collections.unmodifiableList(
|
|
49
|
Arrays.asList(
|
49
|
Arrays.asList(
|
|
50
|
Arrays.asList(1, 9),
|
50
|
Arrays.asList(1, 9),
|
|
51
|
Arrays.asList(3, 3)
|
51
|
Arrays.asList(3, 3)
|
|
52
|
)
|
52
|
)
|
|
53
|
);
|
53
|
);
|
|
54
|
- final long expectedValue = 9l;
|
|
|
|
|
|
54
|
+ long expectedValue = 9l;
|
|
55
|
|
55
|
|
|
56
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1, 9);
|
|
|
|
|
|
56
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1, 9);
|
|
57
|
|
57
|
|
|
58
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
58
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
|
59
|
}
|
59
|
}
|
|
|
|
|
|
|
61
|
@Ignore("Remove to run test")
|
61
|
@Ignore("Remove to run test")
|
|
62
|
@Test
|
62
|
@Test
|
|
63
|
public void largestPalindromeFromDoubleDigitFactors() {
|
63
|
public void largestPalindromeFromDoubleDigitFactors() {
|
|
64
|
- final List<List<Integer>> expected = Collections.unmodifiableList(
|
|
|
|
|
|
64
|
+ List<List<Integer>> expected = Collections.unmodifiableList(
|
|
65
|
Arrays.asList(
|
65
|
Arrays.asList(
|
|
66
|
Arrays.asList(91, 99)
|
66
|
Arrays.asList(91, 99)
|
|
67
|
)
|
67
|
)
|
|
68
|
);
|
68
|
);
|
|
69
|
- final long expectedValue = 9009l;
|
|
|
|
|
|
69
|
+ long expectedValue = 9009l;
|
|
70
|
|
70
|
|
|
71
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(10, 99);
|
|
|
|
|
|
71
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(10, 99);
|
|
72
|
|
72
|
|
|
73
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
73
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
|
74
|
}
|
74
|
}
|
|
|
|
|
|
|
76
|
@Ignore("Remove to run test")
|
76
|
@Ignore("Remove to run test")
|
|
77
|
@Test
|
77
|
@Test
|
|
78
|
public void smallestPalindromeFromDoubleDigitFactors() {
|
78
|
public void smallestPalindromeFromDoubleDigitFactors() {
|
|
79
|
- final List<List<Integer>> expected = Collections.unmodifiableList(
|
|
|
|
|
|
79
|
+ List<List<Integer>> expected = Collections.unmodifiableList(
|
|
80
|
Arrays.asList(
|
80
|
Arrays.asList(
|
|
81
|
Arrays.asList(11, 11)
|
81
|
Arrays.asList(11, 11)
|
|
82
|
)
|
82
|
)
|
|
83
|
);
|
83
|
);
|
|
84
|
- final long expectedValue = 121l;
|
|
|
|
|
|
84
|
+ long expectedValue = 121l;
|
|
85
|
|
85
|
|
|
86
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(10, 99);
|
|
|
|
|
|
86
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(10, 99);
|
|
87
|
|
87
|
|
|
88
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
|
88
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
|
|
89
|
}
|
89
|
}
|
|
|
|
|
|
|
91
|
@Ignore("Remove to run test")
|
91
|
@Ignore("Remove to run test")
|
|
92
|
@Test
|
92
|
@Test
|
|
93
|
public void largestPalindromeFromTripleDigitFactors() {
|
93
|
public void largestPalindromeFromTripleDigitFactors() {
|
|
94
|
- final List<List<Integer>> expected = Collections.unmodifiableList(
|
|
|
|
|
|
94
|
+ List<List<Integer>> expected = Collections.unmodifiableList(
|
|
95
|
Arrays.asList(
|
95
|
Arrays.asList(
|
|
96
|
Arrays.asList(913, 993)
|
96
|
Arrays.asList(913, 993)
|
|
97
|
)
|
97
|
)
|
|
98
|
);
|
98
|
);
|
|
99
|
- final long expectedValue = 906609l;
|
|
|
|
|
|
99
|
+ long expectedValue = 906609l;
|
|
100
|
|
100
|
|
|
101
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(100, 999);
|
|
|
|
|
|
101
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(100, 999);
|
|
102
|
|
102
|
|
|
103
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
103
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
|
104
|
}
|
104
|
}
|
|
|
|
|
|
|
106
|
@Ignore("Remove to run test")
|
106
|
@Ignore("Remove to run test")
|
|
107
|
@Test
|
107
|
@Test
|
|
108
|
public void smallestPalindromeFromTripleDigitFactors() {
|
108
|
public void smallestPalindromeFromTripleDigitFactors() {
|
|
109
|
- final List<List<Integer>> expected = Collections.unmodifiableList(
|
|
|
|
|
|
109
|
+ List<List<Integer>> expected = Collections.unmodifiableList(
|
|
110
|
Arrays.asList(
|
110
|
Arrays.asList(
|
|
111
|
Arrays.asList(101, 101)
|
111
|
Arrays.asList(101, 101)
|
|
112
|
)
|
112
|
)
|
|
113
|
);
|
113
|
);
|
|
114
|
- final long expectedValue = 10201l;
|
|
|
|
|
|
114
|
+ long expectedValue = 10201l;
|
|
115
|
|
115
|
|
|
116
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(100, 999);
|
|
|
|
|
|
116
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(100, 999);
|
|
117
|
|
117
|
|
|
118
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
|
118
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
|
|
119
|
}
|
119
|
}
|
|
|
|
|
|
|
121
|
@Ignore("Remove to run test")
|
121
|
@Ignore("Remove to run test")
|
|
122
|
@Test
|
122
|
@Test
|
|
123
|
public void smallestPalindromeFromQuadDigitFactors() {
|
123
|
public void smallestPalindromeFromQuadDigitFactors() {
|
|
124
|
- final List<List<Integer>> expected = Collections.unmodifiableList(
|
|
|
|
|
|
124
|
+ List<List<Integer>> expected = Collections.unmodifiableList(
|
|
125
|
Arrays.asList(
|
125
|
Arrays.asList(
|
|
126
|
Arrays.asList(1001, 1001)
|
126
|
Arrays.asList(1001, 1001)
|
|
127
|
)
|
127
|
)
|
|
128
|
);
|
128
|
);
|
|
129
|
- final long expectedValue = 1002001l;
|
|
|
|
|
|
129
|
+ long expectedValue = 1002001l;
|
|
130
|
|
130
|
|
|
131
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1000, 9999);
|
|
|
|
|
|
131
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1000, 9999);
|
|
132
|
|
132
|
|
|
133
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
|
133
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
|
|
134
|
}
|
134
|
}
|
|
|
|
|
|
|
136
|
@Ignore("Remove to run test")
|
136
|
@Ignore("Remove to run test")
|
|
137
|
@Test
|
137
|
@Test
|
|
138
|
public void largestPalindromeFromQuadDigitFactors() {
|
138
|
public void largestPalindromeFromQuadDigitFactors() {
|
|
139
|
- final List<List<Integer>> expected = Collections.unmodifiableList(
|
|
|
|
|
|
139
|
+ List<List<Integer>> expected = Collections.unmodifiableList(
|
|
140
|
Arrays.asList(
|
140
|
Arrays.asList(
|
|
141
|
Arrays.asList(9901, 9999)
|
141
|
Arrays.asList(9901, 9999)
|
|
142
|
)
|
142
|
)
|
|
143
|
);
|
143
|
);
|
|
144
|
- final long expectedValue = 99000099l;
|
|
|
|
|
|
144
|
+ long expectedValue = 99000099l;
|
|
145
|
|
145
|
|
|
146
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1000, 9999);
|
|
|
|
|
|
146
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1000, 9999);
|
|
147
|
|
147
|
|
|
148
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
148
|
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.lastKey());
|
|
149
|
}
|
149
|
}
|
|
|
|
|
|
|
155
|
expectedException.expect(NoSuchElementException.class);
|
155
|
expectedException.expect(NoSuchElementException.class);
|
|
156
|
expectedException.expectMessage("no palindrome with factors in the range 1002 to 1003");
|
156
|
expectedException.expectMessage("no palindrome with factors in the range 1002 to 1003");
|
|
157
|
|
157
|
|
|
158
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1002, 1003);
|
|
|
|
|
|
158
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1002, 1003);
|
|
159
|
}
|
159
|
}
|
|
160
|
|
160
|
|
|
161
|
@Ignore("Remove to run test")
|
161
|
@Ignore("Remove to run test")
|
|
|
|
|
|
|
165
|
expectedException.expect(NoSuchElementException.class);
|
165
|
expectedException.expect(NoSuchElementException.class);
|
|
166
|
expectedException.expectMessage("no palindrome with factors in the range 15 to 15");
|
166
|
expectedException.expectMessage("no palindrome with factors in the range 15 to 15");
|
|
167
|
|
167
|
|
|
168
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(15, 15);
|
|
|
|
|
|
168
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(15, 15);
|
|
169
|
}
|
169
|
}
|
|
170
|
|
170
|
|
|
171
|
@Ignore("Remove to run test")
|
171
|
@Ignore("Remove to run test")
|
|
|
|
|
|
|
175
|
expectedException.expect(IllegalArgumentException.class);
|
175
|
expectedException.expect(IllegalArgumentException.class);
|
|
176
|
expectedException.expectMessage("invalid input: min is 10000 and max is 1");
|
176
|
expectedException.expectMessage("invalid input: min is 10000 and max is 1");
|
|
177
|
|
177
|
|
|
178
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(10000, 1);
|
|
|
|
|
|
178
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(10000, 1);
|
|
179
|
}
|
179
|
}
|
|
180
|
|
180
|
|
|
181
|
@Ignore("Remove to run test")
|
181
|
@Ignore("Remove to run test")
|
|
|
|
|
|
|
185
|
expectedException.expect(IllegalArgumentException.class);
|
185
|
expectedException.expect(IllegalArgumentException.class);
|
|
186
|
expectedException.expectMessage("invalid input: min is 2 and max is 1");
|
186
|
expectedException.expectMessage("invalid input: min is 2 and max is 1");
|
|
187
|
|
187
|
|
|
188
|
- final SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(2, 1);
|
|
|
|
|
|
188
|
+ SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(2, 1);
|
|
189
|
}
|
189
|
}
|
|
190
|
|
190
|
|
|
191
|
|
191
|
|