Ad
  • Custom User Avatar

    Apologies. copy and paste error.

    Fixed.

  • Custom User Avatar

    Sorry for not getting back to you - had a hectic weekend.

    I've fixed a bug in my code and your solution should work for all tests now. The last example test case you posted is an old one, so you shouldn't be seeing that. May be a caching issue.

    Test cases should be:

    Test.describe("Basic Tests", function(){
      Test.assertEquals(evolveCalc({Pikachu: [3, 150]}), 1500, 'Expected 1500' );
      Test.assertEquals(evolveCalc({Pidgey: [13, 144]}), 6500, 'Expected 6500' );
      Test.assertEquals(evolveCalc({Pidgey: [13, 144], Pikachu: [3, 150]}), 8000, 'Expected 9500' );
      Test.assertEquals(evolveCalc({Vulpix: [1, 49], Ninetales: [1, 49]}), 500, 'Expected 500');
      Test.assertEquals(evolveCalc({Psyduck: [1, 40]}), 0, 'Expected 0 - Not enough candy.');
      Test.assertEquals(evolveCalc({Snorlax: [1, 130]}), 0, 'Expected 0 - Snorlax can\'t be evolved.');
      Test.assertEquals(evolveCalc({Squirtle: [1, 250], Wartortle: [1, 250]}), 1500, 'Expected 1500');
    });
    
  • Custom User Avatar

    Yeah, you will need to adjust your calculation method slightly from the last one, to take into account the relationship between pokemon in the same family.

    The last of my basic test cases expects 1500 because you can evolve the Wartortle once, and evolve the Squirtle into a Wartortle and then again into a Blastoise. 3 evolutions = 1500 xp.

    The first random test you posted - looks like you won't ever have enough to evolve a Charmeleon so the optimal option for XP would be to transfer them to make enough candy to evolve 3 of your Charmanders. Your Kakuna value is correct, but you can get 1500 XP from your Charmanders.

    The last random test - that's a genuine error. The pokedex had a typo, so Wigglytuff wasn't being included in the Jigglypuff family. This is now fixed.

    Loved your solution for the simplified one btw!

  • Custom User Avatar

    Thanks for this.

    I agree, and have changed the copy. Also added an example that explains the mechanic of accounting for Candy received after evolving a Pidgey.

    :)