Skip to content

Commit 6609226

Browse files
authored
Sync Palindrome Product (exercism#2872)
1 parent 4cf2236 commit 6609226

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

exercises/practice/palindrome-products/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
],
55
"contributors": [
66
"FridaTveit",
7+
"jagdish-15",
78
"jmrunkle",
89
"jssander",
910
"kytrinyx",

exercises/practice/palindrome-products/.meta/tests.toml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[5cff78fe-cf02-459d-85c2-ce584679f887]
6-
description = "finds the smallest palindrome from single digit factors"
13+
description = "find the smallest palindrome from single digit factors"
714

815
[0853f82c-5fc4-44ae-be38-fadb2cced92d]
9-
description = "finds the largest palindrome from single digit factors"
16+
description = "find the largest palindrome from single digit factors"
1017

1118
[66c3b496-bdec-4103-9129-3fcb5a9063e1]
1219
description = "find the smallest palindrome from double digit factors"
@@ -15,13 +22,13 @@ description = "find the smallest palindrome from double digit factors"
1522
description = "find the largest palindrome from double digit factors"
1623

1724
[cecb5a35-46d1-4666-9719-fa2c3af7499d]
18-
description = "find smallest palindrome from triple digit factors"
25+
description = "find the smallest palindrome from triple digit factors"
1926

2027
[edab43e1-c35f-4ea3-8c55-2f31dddd92e5]
2128
description = "find the largest palindrome from triple digit factors"
2229

2330
[4f802b5a-9d74-4026-a70f-b53ff9234e4e]
24-
description = "find smallest palindrome from four digit factors"
31+
description = "find the smallest palindrome from four digit factors"
2532

2633
[787525e0-a5f9-40f3-8cb2-23b52cf5d0be]
2734
description = "find the largest palindrome from four digit factors"
@@ -37,3 +44,6 @@ description = "error result for smallest if min is more than max"
3744

3845
[eeeb5bff-3f47-4b1e-892f-05829277bd74]
3946
description = "error result for largest if min is more than max"
47+
48+
[16481711-26c4-42e0-9180-e2e4e8b29c23]
49+
description = "smallest product does not use the smallest factor"

exercises/practice/palindrome-products/src/test/java/PalindromeCalculatorTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,22 @@ public void errorLargestMinIsMoreThanMax() {
176176
.withMessage("invalid input: min must be <= max");
177177
}
178178

179+
@Disabled("Remove to run test")
180+
@Test
181+
public void smallestProductDoesNotUseTheSmallestFactor() {
182+
List<List<Integer>> expected = Collections.unmodifiableList(
183+
Arrays.asList(
184+
Arrays.asList(3297, 3333)
185+
)
186+
);
187+
long expectedValue = 10988901L;
188+
189+
SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(3215,
190+
4000);
191+
192+
checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
193+
}
194+
179195

180196
private void checkPalindromeWithFactorsMatchesExpected(List<List<Integer>> expectedPalindromeFactors,
181197
long expectedValueOfPalindrome,

0 commit comments

Comments
 (0)