Genevieve is making a video game where players need to trade gems in order to get to the next level. The gems in the game are emeralds , diamonds , and rubies . In the first level, players make three trades of their gems, as shown in the diagram, until they have at least \(10\) rubies .
How many of each gem will a player have when they finish the first level?
How many trades in total will a player have made when they finish this level?
The player starts with only \(1\) , so does not have at least \(10\) , and therefore needs to make trades. The gems after the first three trades are shown.
\(1\) \(\rightarrow\) \(2\) \(\rightarrow\) \(3\) \(\rightarrow\) \(1\) , \(2\)
The player still does not have at least \(10\) , so needs to make trades. The gems after the next three trades are shown.
\(1\) , \(2\) \(\rightarrow\) \(2\) , \(2\) \(\rightarrow\) \(5\) \(\rightarrow\) \(1\) , \(4\)
The player still does not have at least \(10\) , so needs to make trades. However, we can start to see a pattern. After each group of three trades, the player ends up with \(2\) more than they started with. So after the next three trades, the player will have \(1\) and \(6\) , then \(1\) and \(8\) , and then \(1\) and \(10\) . At this point they will have at least \(10\) , so will have finished the level. Therefore, when a player finishes the first level, they will have \(1\) and \(10\) .
Each time the player makes the three trades, they earn \(2\) . Since they started with \(0\) , need \(10\) to finish the level, and \(2 \times 5 = 10\), it follows that they must make the three trades \(5\) times. Therefore, in total, they must make \(3 \times 5 = 15\)Â trades in the first level.
Teacher’s Notes
The diagram that describes the trades and the movement between them is similar to a flowchart that describes a loop in computer science.
A loop in coding allows you to repeat instructions. In this example, you repeat a set of three trades until you have enough rubies to stop. This is an example of a conditional loop since the repetition continues until some condition is met.
When coding, using conditional loops can be tricky since it is possible that the stopping condition might never be met. This is called an endless loop. One way loops might continue forever is if the values being checked in the stopping condition never change. In our problem, we are guaranteed that the loop will stop eventually because we can show that the number of rubies increases each time it repeats.