diff --git a/exercises/practice/change/.meta/tests.toml b/exercises/practice/change/.meta/tests.toml index 5428601a0..2d2f44bc2 100644 --- a/exercises/practice/change/.meta/tests.toml +++ b/exercises/practice/change/.meta/tests.toml @@ -1,6 +1,13 @@ -# 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. [d0ebd0e1-9d27-4609-a654-df5c0ba1d83a] description = "change for 1 cent" @@ -26,6 +33,9 @@ description = "possible change without unit coins available" [9a166411-d35d-4f7f-a007-6724ac266178] description = "another possible change without unit coins available" +[ce0f80d5-51c3-469d-818c-3e69dbd25f75] +description = "a greedy approach is not optimal" + [bbbcc154-e9e9-4209-a4db-dd6d81ec26bb] description = "no coins make 0 change" diff --git a/exercises/practice/change/ChangeTests.fs b/exercises/practice/change/ChangeTests.fs index 20e81311b..34b0641b4 100644 --- a/exercises/practice/change/ChangeTests.fs +++ b/exercises/practice/change/ChangeTests.fs @@ -61,6 +61,13 @@ let ``Another possible change without unit coins available`` () = let expected = Some [4; 4; 4; 5; 5; 5] findFewestCoins coins target |> should equal expected +[] +let ``A greedy approach is not optimal`` () = + let coins = [1; 10; 11] + let target = 20 + let expected = Some [10; 10] + findFewestCoins coins target |> should equal expected + [] let ``No coins make 0 change`` () = let coins = [1; 5; 10; 21; 25]