<s>[INST] General approach for problem for finding sum from $1$ to $N$ when all $a$'s are replaced by $b$'s The problem is:

Find the sum of all the numbers from $1$ to $100$ when all the $6$'s are replaced by $9$'s.

I need some ideas on how to approach this kind of problems? Please explain your ideas, assuming one digit replacements.
 [/INST] Hint:


*

*Can you find the sum $1 + 2 + \dots 100$?

*What are all the values between $1$ and $100$ that have a $6$ in them?  List them.

(Edit:) The process is the same for the numbers $1, \dots , 10$.  You would add up all the values $1 + \dots + 10 = \frac{10 \cdot 11}{2} = 55$.  Then, subtract each number with a $6$ to get $55 - 6 = 49$.  Then, change the $6$ to a $9$, and add it back in: $49 + 9 = 58$.  The same process works for the numbers $1, \dots , 100$:


*

*$1 + \dots + 100 = 5050$.

*Add together all the digits with a $6$:
$$\begin{align}
&6 + 16 + \dots + 56 + 60 + 61 + \dots + 69 + 76 + 86 + 96 
\\
&= (6 + 16 + \dots + 96) + (60 + \dots + 69) - 66
\\
&= (10\cdot 6 + 10 + 20 + \dots + 90) + (10 \cdot 60 + 1 + 2 + 3 + \dots + 9) - 66
\\
&= \left(60 + 10(1 + 2 + \dots + 9)\right) + \left(600 + \frac{9\cdot 10}{2} \right) - 66
\\
&= (60 + 10\cdot 45) + (600 + 45) - 66
\\
&= 1089.
\end{align}$$
EDIT (#$2$):
This process amounts to subtracting all the values with a $6$, and then adding the numbers with a $9$.  Perhaps a quicker way to do this is to add to $5050$, the quantity
$$
9-6 + 19-16 + 29-26 + \dots 59-56 + 90-60+ 91-61 + \dots 99-69 + 79-76 + \dots.
$$
</s>