From 5bf8e066a7713e685d68c9e4d4edfa6357300bb2 Mon Sep 17 00:00:00 2001 From: Katrina Owen Date: Mon, 10 Apr 2023 14:20:06 +0200 Subject: [PATCH 1/3] Sync sum-of-multiples docs with problem-specifications The sum-of-multiples exercise has been overhauled as part of a project to make practice exercises more consistent and friendly. For more context, please see the discussion in the forum, as well as the pull request that updated the exercise in the problem-specifications repository: - https://forum.exercism.org/t/new-project-making-practice-exercises-more-consistent-and-human-across-exercism/3943 - https://github.com/exercism/problem-specifications/pull/2249 --- .../sum-of-multiples/.docs/instructions.md | 29 ++++++++++++------- .../sum-of-multiples/.docs/introduction.md | 6 ++++ 2 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 exercises/practice/sum-of-multiples/.docs/introduction.md diff --git a/exercises/practice/sum-of-multiples/.docs/instructions.md b/exercises/practice/sum-of-multiples/.docs/instructions.md index 7b7ec006e2..9c824bf1d5 100644 --- a/exercises/practice/sum-of-multiples/.docs/instructions.md +++ b/exercises/practice/sum-of-multiples/.docs/instructions.md @@ -1,18 +1,27 @@ # Instructions -Given a list of factors and a limit, add up all the unique multiples of the factors that are less than the limit. -All inputs will be greater than or equal to zero. +Your task is to write the code that calculates the energy points that get awarded to players when they complete a level. -## Example +The points awarded depend on two things: -Suppose the limit is 20 and the list of factors is [3, 5]. -We need to find the sum of all unique multiples of 3 and 5 that are less than 20. +- The level (a number) that the player completed. +- The base value of each magical item collected by the player during that level. -Multiples of 3 less than 20: 3, 6, 9, 12, 15, 18 -Multiples of 5 less than 20: 5, 10, 15 +The energy points are awarded according to the following rules: -The unique multiples are: 3, 5, 6, 9, 10, 12, 15, 18 +1. For each magical item, take the base value and find all the multiples of that value that are less than or equal to the level number. +2. Combine the sets of numbers. +3. Remove any duplicates. +4. Calculate the sum of all the numbers that are left. -The sum of the unique multiples is: 3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 = 78 +Let's look an example: -So, the answer is 78. +**The player completed level 20 and found two magical items with base values of 3 and 5.** + +To calculate the energy points earned by the player, we need to find all the unique multiples of these base values that are less than or equal to level 20. + +- Multiples of 3 up to 20: `{3, 6, 9, 12, 15, 18}` +- Multiples of 5 up to 20: `{5, 10, 15, 20}` +- Combine the sets and remove duplicates: `{3, 5, 6, 9, 10, 12, 15, 18, 20}` +- Sum the unique multiples: `3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 + 20 = 98` +- Therefore, the player earns **98** energy points for completing level 20 and finding the two magical items with base values of 3 and 5. diff --git a/exercises/practice/sum-of-multiples/.docs/introduction.md b/exercises/practice/sum-of-multiples/.docs/introduction.md new file mode 100644 index 0000000000..69cabeed5a --- /dev/null +++ b/exercises/practice/sum-of-multiples/.docs/introduction.md @@ -0,0 +1,6 @@ +# Introduction + +You work for a company that makes an online, fantasy-survival game. + +When a player finishes a level, they are awarded energy points. +The amount of energy awarded depends on which magical items the player found while exploring that level. From 31707e6bc9a798b71f3ad9b25de5da7c1246e5e3 Mon Sep 17 00:00:00 2001 From: Katrina Owen Date: Tue, 11 Apr 2023 18:39:04 +0200 Subject: [PATCH 2/3] Sync sum-of-multiples docs with problem-specifications There were a few follow-on tweaks to sum-of-multiples. For context, this is part of the project to overhaul all the practice exercises. You can read about that here: https://forum.exercism.org/t/new-project-making-practice-exercises-more-consistent-and-human-across-exercism/3943 ---- If you approve this pull request, I will eventually merge it. However, if you are happy with this change **please merge the pull request**, as it will get the changes into the hands of the students much more quickly. If this pull request contradicts the exercise on your track, **please add a review with _request changes_**. This will block the pull request from getting merged. Otherwise we aim to take an optimistic merging approach. If you wish to suggest tweaks to these changes, please open a pull request to the exercism/problem-specifications repository to discuss, so that everyone who has an interest in the shared exercise descriptions can participate. --- .../sum-of-multiples/.docs/instructions.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/exercises/practice/sum-of-multiples/.docs/instructions.md b/exercises/practice/sum-of-multiples/.docs/instructions.md index 9c824bf1d5..d69f890e9d 100644 --- a/exercises/practice/sum-of-multiples/.docs/instructions.md +++ b/exercises/practice/sum-of-multiples/.docs/instructions.md @@ -9,19 +9,19 @@ The points awarded depend on two things: The energy points are awarded according to the following rules: -1. For each magical item, take the base value and find all the multiples of that value that are less than or equal to the level number. +1. For each magical item, take the base value and find all the multiples of that value that are less than the level number. 2. Combine the sets of numbers. 3. Remove any duplicates. 4. Calculate the sum of all the numbers that are left. -Let's look an example: +Let's look at an example: **The player completed level 20 and found two magical items with base values of 3 and 5.** -To calculate the energy points earned by the player, we need to find all the unique multiples of these base values that are less than or equal to level 20. +To calculate the energy points earned by the player, we need to find all the unique multiples of these base values that are less than level 20. -- Multiples of 3 up to 20: `{3, 6, 9, 12, 15, 18}` -- Multiples of 5 up to 20: `{5, 10, 15, 20}` -- Combine the sets and remove duplicates: `{3, 5, 6, 9, 10, 12, 15, 18, 20}` -- Sum the unique multiples: `3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 + 20 = 98` -- Therefore, the player earns **98** energy points for completing level 20 and finding the two magical items with base values of 3 and 5. +- Multiples of 3 less than 20: `{3, 6, 9, 12, 15, 18}` +- Multiples of 5 less than 20: `{5, 10, 15}` +- Combine the sets and remove duplicates: `{3, 5, 6, 9, 10, 12, 15, 18}` +- Sum the unique multiples: `3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 = 78` +- Therefore, the player earns **78** energy points for completing level 20 and finding the two magical items with base values of 3 and 5. From 0484f952a608d5ae13be7ab9852c7b07328a11b3 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Tue, 11 Apr 2023 11:26:21 -0700 Subject: [PATCH 3/3] Update instructions.md Resolved merge conflicts, and am now attempting to re-push to repo. --- exercises/practice/sum-of-multiples/.docs/instructions.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/practice/sum-of-multiples/.docs/instructions.md b/exercises/practice/sum-of-multiples/.docs/instructions.md index 46d5781d1c..e9a25636e5 100644 --- a/exercises/practice/sum-of-multiples/.docs/instructions.md +++ b/exercises/practice/sum-of-multiples/.docs/instructions.md @@ -14,7 +14,6 @@ The energy points are awarded according to the following rules: 3. Remove any duplicates. 4. Calculate the sum of all the numbers that are left. - Let's look at an example: **The player completed level 20 and found two magical items with base values of 3 and 5.** @@ -25,4 +24,4 @@ To calculate the energy points earned by the player, we need to find all the uni - Multiples of 5 less than 20: `{5, 10, 15}` - Combine the sets and remove duplicates: `{3, 5, 6, 9, 10, 12, 15, 18}` - Sum the unique multiples: `3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 = 78` -- Therefore, the player earns **78** energy points for completing level 20 and finding the two magical items with base values of 3 and 5 \ No newline at end of file +- Therefore, the player earns **78** energy points for completing level 20 and finding the two magical items with base values of 3 and 5