We can know from a series of conditions in the title that the yellow ball has changed.
While the number of other balls has not changed.
Therefore, the change of the percentage of yellow balls in other balls can be used to calculate the number of balls in the bag.
The yellow ball accounts for 5/ 12-5=5/7 of the other balls.
The yellow ball accounts for1/2-1=11of other balls.
6/(1-5/7) = 6/(2/7) = 21other balls.
Now the number of yellow balls is 21*11= 21. Now there are 42 balls in the bag, 2 1+2 1=42.