I’m building a math application (not homework) and I want to build a component that allows players to drag-and-drop 1’s, 10’s, 100’s, etc to complete problems and *a bonus reward* if they do it in the fewest moves possible–**How can I calculate this?** e.g.

`50 + X = 96 `

where X is a randomly generated integer and the player *is modifying* X during play. So, the player needs to make X=46, but starts at 121. For example,

`if X is initially 121, and player needs to get to 46 `

player thinks, “cool, i’ll just subtract 75”

`remove 7x 10's, remove 5x 1's - 12 moves `

but it turns out, there’s a faster way to do it:

`remove 1x 100's, add 2x 10's, add 5x 1's - 8 moves `

Is there an existing algorithm for this? It would be helpful to calculate this for anything up to 10,000 where I can calculate the minimum number of moves required.