Candy Calc
A calculator for Exp. Candy optimization in Pokémon games. Read the FAQ for more information.
FAQ
What does this calculator do?

It calculates the optimal amount of candy you should feed your Pokémon to reach a certain level.
This can be useful for Hyper Training, evolving, or teaching a levelup move to a Pokémon.
What are Exp. Candies?

An Exp. Candy is a new kind of item introduced in Pokémon Sword & Shield. These grant Exp. Points when consumed by Pokémon. As shown below, there are 5 sizes, each with a different Experience yield:
Candy Exp. Yield Exp. Candy XS 100 Exp. Candy S 800 Exp. Candy M 3,000 Exp. Candy L 10,000 Exp. Candy XL 30,000 Exp. Candies are also obtainable in Pokémon Legends: Arceus and Pokémon Scarlet & Violet.
How do you use this calculator?
Enter the species of your Pokémon (the Experience Curve will be autocompleted), its current level, and the target level you want it to reach. Additionally, you may indicate how many candies of each type are left in your Bag. Then, click "Calculate" and voilà!
Where do you find Exp. Candy?

These items are drop rewards from Max Raid Battles. Raids with a higher number of stars will output larger candy.
Additionally, hikers spread throughout the Wild Area may hand out candy in exchange for Watts and you may also receive them as prizes from the Battle Cafés. However, farming candy through these methods is less efficient than raids.
What does optimal mean?

In a perfect world, candy is an unlimited resource that streams directly into the bellies of your dearest battle companions. Since this is not the case, it is wise to carefully allocate your candy in order to maximize their usefulness and prevent any waste of resources.
To calculate the optimal distribution of candy, this calculator solves a mixedinteger linear programming problem. In this problem, the objective function is set to minimize the number of candy required (c_{i}) to meet certain Experience (E). At the same time, the surplus of Exp. Points is also minimized by taking into account the yields of each candy variant (Y_{i}). In mathematical notation, this is represented as follows:
What about Rare Candy?

Unlike Exp. Candy, Rare Candy yield an exponential amount of Experience as level increases. This means that consuming a Rare Candy at Lv. 1 does not equate consuming a Rare Candy at Lv. 99. Conversely, an Exp. Candy XL grants a fixed amount of Exp. Points regardless of level. Since the candy distribution problem has been posed as a linear problem, Rare Candies are not factored in.
If you want to take Rare Candies into consideration, lower the target level by the amount of Rare Candies you want to feed your Pokémon and remember that these should be applied after the Exp. Candy.
What about other modifiers?
The yield of Exp. Candies is not modified by other factors such as holding a Lucky Egg.
I have feedback/questions/bug report.
Contact me on Twitter or open an Issue in this project's repository.