Skip to content

Commit b255a77

Browse files
authored
Sync sum-of-multiples docs with problem-specifications (#188)
* 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 - exercism/problem-specifications#2249 * Run configlet sync on sum-of-multiples
1 parent a7e3bc2 commit b255a77

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed
Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
# Instructions
22

3-
Given a list of factors and a limit, add up all the unique multiples of the factors that are less than the limit.
4-
All inputs will be greater than or equal to zero.
3+
Your task is to write the code that calculates the energy points that get awarded to players when they complete a level.
54

6-
## Example
5+
The points awarded depend on two things:
76

8-
Suppose the limit is 20 and the list of factors is [3, 5].
9-
We need to find the sum of all unique multiples of 3 and 5 that are less than 20.
7+
- The level (a number) that the player completed.
8+
- The base value of each magical item collected by the player during that level.
109

11-
Multiples of 3 less than 20: 3, 6, 9, 12, 15, 18
12-
Multiples of 5 less than 20: 5, 10, 15
10+
The energy points are awarded according to the following rules:
1311

14-
The unique multiples are: 3, 5, 6, 9, 10, 12, 15, 18
12+
1. For each magical item, take the base value and find all the multiples of that value that are less than the level number.
13+
2. Combine the sets of numbers.
14+
3. Remove any duplicates.
15+
4. Calculate the sum of all the numbers that are left.
1516

16-
The sum of the unique multiples is: 3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 = 78
17+
Let's look at an example:
1718

18-
So, the answer is 78.
19+
**The player completed level 20 and found two magical items with base values of 3 and 5.**
20+
21+
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.
22+
23+
- Multiples of 3 less than 20: `{3, 6, 9, 12, 15, 18}`
24+
- Multiples of 5 less than 20: `{5, 10, 15}`
25+
- Combine the sets and remove duplicates: `{3, 5, 6, 9, 10, 12, 15, 18}`
26+
- Sum the unique multiples: `3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 = 78`
27+
- Therefore, the player earns **78** energy points for completing level 20 and finding the two magical items with base values of 3 and 5.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Introduction
2+
3+
You work for a company that makes an online, fantasy-survival game.
4+
5+
When a player finishes a level, they are awarded energy points.
6+
The amount of energy awarded depends on which magical items the player found while exploring that level.

0 commit comments

Comments
 (0)