Question: Problem # 3 : Daniel's Pokemon Gacha Game Obsession Daniel is currently playing the hottest mobile game titled Pokemon Super Duper Ultra Ruby Diamond Phantom
Problem #: Daniel's Pokemon Gacha Game Obsession
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 rolls The bad thing is that Daniel is currently addicted to it Addiction 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 integer Pokemon 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 Sylveon 'Rayquaza' 'Slakoth', tells 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 on until 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 pokerollingSylveon 'Groudon', 'Pikachu', This 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 it We 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 Sylveon 'Groudon' because we are left with only PokeGem in the end, but we did get Sylveon and Groudon.
Function Call
Expected Return Value integer & list pair
pokerollingSylveon 'Bulbasaur', 'Pikachu',
Sylveon 'Bulbasaur'
pokerollingMewtwo 'Rayquaza',
'Lucario', 'Groudon', 'Pikachu',
Mewtwo 'Rayquaza', 'Lucario', 'Groudon', 'Pikachu'
pokerollingSylveon 'Pikachu', 'Charizard', 'Lucario',
Sylveon 'Pikachu', 'Charizard'
pokerollingSylveon 'Groudon', 'Pikachu',
Sylveon 'Groudon'
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
