From 54d59090f8d2b63e57959df2850603a37fae51e8 Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Sat, 30 Nov 2024 23:44:50 +0200 Subject: [PATCH 1/4] Add a story to the change exercise --- .../{description.md => instructions.md} | 8 +++--- exercises/change/introduction.md | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) rename exercises/change/{description.md => instructions.md} (50%) create mode 100644 exercises/change/introduction.md diff --git a/exercises/change/description.md b/exercises/change/instructions.md similarity index 50% rename from exercises/change/description.md rename to exercises/change/instructions.md index 6dac387fc8..f4ab450fb4 100644 --- a/exercises/change/description.md +++ b/exercises/change/instructions.md @@ -1,11 +1,11 @@ -# Description +# Instructions Correctly determine the fewest number of coins to be given to a customer such that the sum of the coins' value would equal the correct amount of change. -## For example +## Examples -- An input of 15 with [1, 5, 10, 25, 100] should return one nickel (5) and one dime (10) or [5, 10] -- An input of 40 with [1, 5, 10, 25, 100] should return one nickel (5) and one dime (10) and one quarter (25) or [5, 10, 25] +- An amount of 15 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5 and one coin of value 10, or [5, 10]. +- An amount of 40 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5, one coin of value 10, and one coin of value 25, or [5, 10, 25]. ## Edge cases diff --git a/exercises/change/introduction.md b/exercises/change/introduction.md new file mode 100644 index 0000000000..3d20d98b75 --- /dev/null +++ b/exercises/change/introduction.md @@ -0,0 +1,26 @@ +# Introduction + +In the mystical village of Coinholt, you stand behind the counter of your bakery, arranging a fresh batch of pastries. +The door creaks open, and in walks Denara, a skilled merchant with a keen eye for quality goods. +After a quick meal, she slides a shimmering golden coin across the counter, worth 100 coins. + +You smile, taking the coin, and glance at the total on your ledger: 88 coins. +That means you need to return 12 coins in change. + +Denara holds out her hand expectantly. +"Just give me the fewest coins," she says with a smile. +"My pouch is already full, and I don't want to risk losing them on the road." + +You know you have a few options. +"We have Lumis (worth 10 coins), Viras (worth 5 coins), and Zenth (worth 2 coins) available for change." + +You quickly calculate the possibilities in your head: + +- one Lumis (10) + one Zenth (2) = 2 coins total +- two Viras (2 × 5) + one Zenth (2) = 3 coins total +- six Zenth (2 × 6) = 6 coins total + +"The best choice is two coins: one Lumis and one Zenth," you say, handing her the change. + +Denara smiles, clearly impressed. +"As always, you've got it right." From 2a7a7aa6c19724887b60a4cd0137d4faab555624 Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:04:24 +0200 Subject: [PATCH 2/4] forum suggestions (change base unit, remove ledger word) --- exercises/change/introduction.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises/change/introduction.md b/exercises/change/introduction.md index 3d20d98b75..b4f8308a1b 100644 --- a/exercises/change/introduction.md +++ b/exercises/change/introduction.md @@ -2,23 +2,23 @@ In the mystical village of Coinholt, you stand behind the counter of your bakery, arranging a fresh batch of pastries. The door creaks open, and in walks Denara, a skilled merchant with a keen eye for quality goods. -After a quick meal, she slides a shimmering golden coin across the counter, worth 100 coins. +After a quick meal, she slides a shimmering coin across the counter, representing a value of 100 units. -You smile, taking the coin, and glance at the total on your ledger: 88 coins. -That means you need to return 12 coins in change. +You smile, taking the coin, and glance at the total cost of the meal: 88 units. +That means you need to return 12 units in change. Denara holds out her hand expectantly. "Just give me the fewest coins," she says with a smile. "My pouch is already full, and I don't want to risk losing them on the road." You know you have a few options. -"We have Lumis (worth 10 coins), Viras (worth 5 coins), and Zenth (worth 2 coins) available for change." +"We have Lumis (worth 10 units), Viras (worth 5 units), and Zenth (worth 2 units) available for change." You quickly calculate the possibilities in your head: -- one Lumis (10) + one Zenth (2) = 2 coins total -- two Viras (2 × 5) + one Zenth (2) = 3 coins total -- six Zenth (2 × 6) = 6 coins total +- one Lumis (1 × 10 units) + one Zenth (1 × 2 units) = 2 coins total +- two Viras (2 × 5 units) + one Zenth (1 × 2 units) = 3 coins total +- six Zenth (6 × 2 units) = 6 coins total "The best choice is two coins: one Lumis and one Zenth," you say, handing her the change. From 821b5fa570f8741445c31f83c7de15df8dea4a9f Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Thu, 19 Dec 2024 11:14:01 +0200 Subject: [PATCH 3/4] forum suggestions (remove edge cases from instructions) --- exercises/change/instructions.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/exercises/change/instructions.md b/exercises/change/instructions.md index f4ab450fb4..8d59ce2568 100644 --- a/exercises/change/instructions.md +++ b/exercises/change/instructions.md @@ -6,9 +6,3 @@ Correctly determine the fewest number of coins to be given to a customer such th - An amount of 15 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5 and one coin of value 10, or [5, 10]. - An amount of 40 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5, one coin of value 10, and one coin of value 25, or [5, 10, 25]. - -## Edge cases - -- Does your algorithm work for any given set of coins? -- Can you ask for negative change? -- Can you ask for a change value smaller than the smallest coin value? From 9eea129349a5ead1e82000e137f4f4c0f78cc63a Mon Sep 17 00:00:00 2001 From: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> Date: Thu, 19 Dec 2024 11:21:48 +0200 Subject: [PATCH 4/4] rephrase instruction --- exercises/change/instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/change/instructions.md b/exercises/change/instructions.md index 8d59ce2568..5887f4cb69 100644 --- a/exercises/change/instructions.md +++ b/exercises/change/instructions.md @@ -1,6 +1,6 @@ # Instructions -Correctly determine the fewest number of coins to be given to a customer such that the sum of the coins' value would equal the correct amount of change. +Determine the fewest number of coins to give a customer so that the sum of their values equals the correct amount of change. ## Examples