From 40af38f46d7f6586023fabed7efd89b7a76294ce Mon Sep 17 00:00:00 2001 From: Andrew Garvin Date: Sat, 11 Apr 2026 10:47:42 -0400 Subject: [PATCH 1/3] Added missing tests to change --- exercises/practice/change/.meta/tests.toml | 61 ++++++++++++------- .../src/test/kotlin/ChangeCalculatorTest.kt | 19 +++++- 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/exercises/practice/change/.meta/tests.toml b/exercises/practice/change/.meta/tests.toml index 72b93b58..2d2f44bc 100644 --- a/exercises/practice/change/.meta/tests.toml +++ b/exercises/practice/change/.meta/tests.toml @@ -1,34 +1,49 @@ -[canonical-tests] +# 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. -# single coin change -"36887bea-7f92-4a9c-b0cc-c0e886b3ecc8" = true +[d0ebd0e1-9d27-4609-a654-df5c0ba1d83a] +description = "change for 1 cent" -# multiple coin change -"cef21ccc-0811-4e6e-af44-f011e7eab6c6" = true +[36887bea-7f92-4a9c-b0cc-c0e886b3ecc8] +description = "single coin change" -# change with Lilliputian Coins -"d60952bc-0c1a-4571-bf0c-41be72690cb3" = true +[cef21ccc-0811-4e6e-af44-f011e7eab6c6] +description = "multiple coin change" -# change with Lower Elbonia Coins -"408390b9-fafa-4bb9-b608-ffe6036edb6c" = true +[d60952bc-0c1a-4571-bf0c-41be72690cb3] +description = "change with Lilliputian Coins" -# large target values -"7421a4cb-1c48-4bf9-99c7-7f049689132f" = true +[408390b9-fafa-4bb9-b608-ffe6036edb6c] +description = "change with Lower Elbonia Coins" -# possible change without unit coins available -"f79d2e9b-0ae3-4d6a-bb58-dc978b0dba28" = true +[7421a4cb-1c48-4bf9-99c7-7f049689132f] +description = "large target values" -# another possible change without unit coins available -"9a166411-d35d-4f7f-a007-6724ac266178" = true +[f79d2e9b-0ae3-4d6a-bb58-dc978b0dba28] +description = "possible change without unit coins available" -# no coins make 0 change -"bbbcc154-e9e9-4209-a4db-dd6d81ec26bb" = true +[9a166411-d35d-4f7f-a007-6724ac266178] +description = "another possible change without unit coins available" -# error testing for change smaller than the smallest of coins -"c8b81d5a-49bd-4b61-af73-8ee5383a2ce1" = true +[ce0f80d5-51c3-469d-818c-3e69dbd25f75] +description = "a greedy approach is not optimal" -# error if no combination can add up to target -"3c43e3e4-63f9-46ac-9476-a67516e98f68" = true +[bbbcc154-e9e9-4209-a4db-dd6d81ec26bb] +description = "no coins make 0 change" -# cannot find negative change values -"8fe1f076-9b2d-4f44-89fe-8a6ccd63c8f3" = true +[c8b81d5a-49bd-4b61-af73-8ee5383a2ce1] +description = "error testing for change smaller than the smallest of coins" + +[3c43e3e4-63f9-46ac-9476-a67516e98f68] +description = "error if no combination can add up to target" + +[8fe1f076-9b2d-4f44-89fe-8a6ccd63c8f3] +description = "cannot find negative change values" diff --git a/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt b/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt index a5c03c16..030fcc59 100644 --- a/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt +++ b/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt @@ -10,6 +10,12 @@ class ChangeCalculatorTest { @JvmField var expectedException: ExpectedException = ExpectedException.none() + @Test + fun `change for 1 cent`() { + var computedChange = ChangeCalculator(listOf(1, 5, 10, 25)).computeMostEfficientChange(1) + assertContainsExactly(computedChange, listOf(1)) + } + @Test fun singleCoinChange() { val computedChange = ChangeCalculator(listOf(1, 5, 10, 25, 100)).computeMostEfficientChange(25) @@ -41,8 +47,10 @@ class ChangeCalculatorTest { @Test fun largeTargetValues() { val computedChange = ChangeCalculator(listOf(1, 2, 5, 10, 20, 50, 100)).computeMostEfficientChange(999) - assertContainsExactly(computedChange, - listOf(2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100)) + assertContainsExactly( + computedChange, + listOf(2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100) + ) } @Ignore @@ -59,6 +67,13 @@ class ChangeCalculatorTest { assertContainsExactly(computedChange, listOf(4, 4, 4, 5, 5, 5)) } + @Ignore + @Test + fun `a greedy approach is not optimal`() { + val computedChange = ChangeCalculator(listOf(1, 10, 11)).computeMostEfficientChange(20) + assertContainsExactly(computedChange, listOf(10, 10)) + } + @Ignore @Test fun noCoinsMake0Change() { From e59e9d65615fe6d3d6de03cc183c5af10897b5c3 Mon Sep 17 00:00:00 2001 From: Andrew Garvin Date: Sat, 11 Apr 2026 10:57:32 -0400 Subject: [PATCH 2/3] "change for 1 cent" test is not ignored, and "single coin change" starts ignored --- .../practice/change/src/test/kotlin/ChangeCalculatorTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt b/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt index 030fcc59..b45ca693 100644 --- a/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt +++ b/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt @@ -16,6 +16,7 @@ class ChangeCalculatorTest { assertContainsExactly(computedChange, listOf(1)) } + @Ignore @Test fun singleCoinChange() { val computedChange = ChangeCalculator(listOf(1, 5, 10, 25, 100)).computeMostEfficientChange(25) From 259b8957dd189a50d7faf66b71a7c7abbbebd3cc Mon Sep 17 00:00:00 2001 From: Andrew Garvin Date: Sat, 11 Apr 2026 11:04:07 -0400 Subject: [PATCH 3/3] Test names use backticks and spaces --- .../src/test/kotlin/ChangeCalculatorTest.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt b/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt index b45ca693..d6a8a421 100644 --- a/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt +++ b/exercises/practice/change/src/test/kotlin/ChangeCalculatorTest.kt @@ -18,35 +18,35 @@ class ChangeCalculatorTest { @Ignore @Test - fun singleCoinChange() { + fun `single coin change`() { val computedChange = ChangeCalculator(listOf(1, 5, 10, 25, 100)).computeMostEfficientChange(25) assertContainsExactly(computedChange, listOf(25)) } @Ignore @Test - fun multipleCoinChange() { + fun `multiple coin change`() { val computedChange = ChangeCalculator(listOf(1, 5, 10, 25, 100)).computeMostEfficientChange(15) assertContainsExactly(computedChange, listOf(5, 10)) } @Ignore @Test - fun changeWithLilliputianCoins() { + fun `change with Lilliputian Coins`() { val computedChange = ChangeCalculator(listOf(1, 4, 15, 20, 50)).computeMostEfficientChange(23) assertContainsExactly(computedChange, listOf(4, 4, 15)) } @Ignore @Test - fun changeWithLowerElboniaCoins() { + fun `change with Lower Elbonia Coins`() { val computedChange = ChangeCalculator(listOf(1, 5, 10, 21, 25)).computeMostEfficientChange(63) assertContainsExactly(computedChange, listOf(21, 21, 21)) } @Ignore @Test - fun largeTargetValues() { + fun `large target values`() { val computedChange = ChangeCalculator(listOf(1, 2, 5, 10, 20, 50, 100)).computeMostEfficientChange(999) assertContainsExactly( computedChange, @@ -56,14 +56,14 @@ class ChangeCalculatorTest { @Ignore @Test - fun possibleChangeWithoutUnitCoinsAvailable() { + fun `possible change without unit coins available`() { val computedChange = ChangeCalculator(listOf(2, 5, 10, 20, 50)).computeMostEfficientChange(21) assertContainsExactly(computedChange, listOf(2, 2, 2, 5, 10)) } @Ignore @Test - fun anotherPossibleChangeWithoutUnitCoinsAvailable() { + fun `another possible change without unit coins available`() { val computedChange = ChangeCalculator(listOf(4, 5)).computeMostEfficientChange(27) assertContainsExactly(computedChange, listOf(4, 4, 4, 5, 5, 5)) } @@ -77,14 +77,14 @@ class ChangeCalculatorTest { @Ignore @Test - fun noCoinsMake0Change() { + fun `no coins make 0 change`() { val computedChange = ChangeCalculator(listOf(1, 5, 10, 21, 25)).computeMostEfficientChange(0) assertEquals(0, computedChange.size) } @Ignore @Test - fun errorTestingForChangeSmallerThanTheSmallestCoin() { + fun `error testing for change smaller than the smallest of coins`() { val changeCalculator = ChangeCalculator(listOf(5, 10)) expectedException.expect(IllegalArgumentException::class.java) @@ -95,7 +95,7 @@ class ChangeCalculatorTest { @Ignore @Test - fun errorIfNoCombinationCanAddUpToTarget() { + fun `error if no combination can add up to target`() { val changeCalculator = ChangeCalculator(listOf(5, 10)) expectedException.expect(IllegalArgumentException::class.java) @@ -106,7 +106,7 @@ class ChangeCalculatorTest { @Ignore @Test - fun cannotFindNegativeChangeValues() { + fun `cannot find negative change values`() { val changeCalculator = ChangeCalculator(listOf(1, 2, 5)) expectedException.expect(IllegalArgumentException::class.java)