Skip to content

Commit

Permalink
Sync Palindrome Product (#2872)
Browse files Browse the repository at this point in the history
  • Loading branch information
jagdish-15 authored Dec 28, 2024
1 parent 4cf2236 commit 6609226
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions exercises/practice/palindrome-products/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"contributors": [
"FridaTveit",
"jagdish-15",
"jmrunkle",
"jssander",
"kytrinyx",
Expand Down
24 changes: 17 additions & 7 deletions exercises/practice/palindrome-products/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

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

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

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

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

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

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

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

[eeeb5bff-3f47-4b1e-892f-05829277bd74]
description = "error result for largest if min is more than max"

[16481711-26c4-42e0-9180-e2e4e8b29c23]
description = "smallest product does not use the smallest factor"
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,22 @@ public void errorLargestMinIsMoreThanMax() {
.withMessage("invalid input: min must be <= max");
}

@Disabled("Remove to run test")
@Test
public void smallestProductDoesNotUseTheSmallestFactor() {
List<List<Integer>> expected = Collections.unmodifiableList(
Arrays.asList(
Arrays.asList(3297, 3333)
)
);
long expectedValue = 10988901L;

SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(3215,
4000);

checkPalindromeWithFactorsMatchesExpected(expected, expectedValue, palindromes, palindromes.firstKey());
}


private void checkPalindromeWithFactorsMatchesExpected(List<List<Integer>> expectedPalindromeFactors,
long expectedValueOfPalindrome,
Expand Down

0 comments on commit 6609226

Please sign in to comment.