Skip to content

Commit

Permalink
sync change exercise (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
glennj authored Mar 28, 2024
1 parent 94b1cb2 commit 8107b0b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
16 changes: 13 additions & 3 deletions exercises/practice/change/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"

Expand Down
9 changes: 9 additions & 0 deletions exercises/practice/change/change.bats
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ load bats-extra
assert_output "$expected"
}

@test "a greedy approach is not optimal" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
expected="10 10"
coins=(1 10 11)
run bash change.sh 20 "${coins[@]}"
assert_success
assert_output "$expected"
}

@test "error testing for change smaller than the smallest of coins" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
expected="can't make target with given coins"
Expand Down

0 comments on commit 8107b0b

Please sign in to comment.