Question: Problem # 3 : Daniel's Pokemon Gacha Game Obsession without using while loops Daniel is currently playing the hottest mobile game titled Pokemon Super Duper
Problem #: Daniel's Pokemon Gacha Game Obsession
without using while loops
Daniel is currently playing the hottest mobile game titled "Pokemon Super Duper Ultra Ruby Diamond Phantom Sapphire Omega Red, Demon's Return". The good thing is that this is a gacha game. In a gacha game you rollspin for special units, in this case special Pokemon, using ingame currency. You can also spend real world money to get more rollsThe bad thing is that Daniel is currently addicted to itAddiction aside, he wants us to help him write a function which determines what kind of Pokemon he will end up getting after using all of his PokeGems the currency used for rolling
Complete the function pokerolling, which takes two parameters. The first parameter, named pokegems, indicates the number of PokeGems that Daniel currently possesses. The second parameter, named pokemonpool, is a list of elements that follows the pattern Pokemon name', an integerPokemon name indicates the Pokemon that you are currently rolling for, while the integer indicates the number of rolls until you can obtain the Pokemon. As an example: the list SylveonRayquazaSlakothtells us that the current Pokemon that the user is rolling for is "Sylveon", indicated as the leftmost entry of the list, and after rolls the user will be able to obtain Sylveon and move on to rolling for Rayquaza, and so onuntil the Pokemon pool is empty or the user runs out of PokeGems.
Each roll in the Pokemon pool costs PokeGems
The function pokerolling should return two values, the first value indicating the remaining PokeGems, either from finishing rolling through all of the Pokemon pools, or from running out of PokeGems before winning all the Pokemon. The second value is a list of Pokemon that you have received from the pool.
Let's go over an example.
Suppose we call pokerollingSylveonGroudonPikachuThis tells us that we have a total of PokeGems at the start.
We will be processing the Pokemon pool from lefttoright, so we start with Sylveon, which requires a total of rolls in order to obtain itWe are able to obtain it because we have enough PokeGems to roll times which gives us a Sylveon in our output. We are left with PokeGems
Next, since we have enough for obtaining Groudon, we proceed to roll for him. Since we do rolls each costing us PokeGems we deduct gems from our total. We add Groudon to our output, and, after taking gems away, we have only PokeGems left.
Again, we will only stop if we run out of PokeGems or the Pokemon pool is empty. Clearly, we can still roll for Pikachu, but only once, and we do not get Pikachu because it requires rolls in total and we can only do This brings us down to PokeGem in total.
Finally, as return value we will be returning SylveonGroudonbecause we are left with only PokeGem in the end, but we did get Sylveon and Groudon.
Function Call
Expected Return Value integer & list pair
pokerollingSylveonBulbasaurPikachu
SylveonBulbasaur
pokerollingMewtwoRayquaza
'Lucario', GroudonPikachu
MewtwoRayquaza 'Lucario', 'Groudon', 'Pikachu'
pokerollingSylveonPikachuCharizardLucario
SylveonPikachu 'Charizard'
pokerollingSylveonGroudonPikachu
SylveonGroudon
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
