For an simple approach to this problem one could cut up the 10 NM into a number of segments.
Suppose you would use 20 segments of 0.5 NM to represent the 10 NM
Now calculate the ground speed at the start of the segment and assume that it is constant over the whole segment. Then calculate the time it takes to reach the end of the segment and calculate the new altitude. With this new altitude calculate the speed for the next segment. And so on until the end of the 20th segment is reached.
This is called the
Euler method
To improve accuracy it's easiest to increase the number of segments. However that become computationally very costly soon.
For more accuracy, you could improve by using the backward Euler method or go for higher order models like
RK4.
These methods are more work to implement than just adding more segments but they give the required accuracy more efficiently.