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.
Your task is to write the code that calculates the energy points that get awarded to players when they complete a level.
The points awarded depend on two things:
The energy points are awarded according to the following rules:
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 level 20.
{3, 6, 9, 12, 15, 18}
{5, 10, 15}
{3, 5, 6, 9, 10, 12, 15, 18}
3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 = 78
The trick to this exercise understanding how to iterate accross a range of numbers as well as check a Collection for any multiples that are divisible by a number. Try using the Spotter to look up potential classes and browse the categories of methods in those classes.
Also remember that the Pharo environment is extensively cross referenced. You can right click on any class or method and browse "references" to a class (to see how it might be created), as well as "senders" of a method (to see how it might be used).
Sign up to Exercism to learn and master Pharo with 45 exercises, and real human mentoring, all for free.