Chewbacca and numbers to print

https://ide.codingblocks.com/s/623132 this is the piece of the code can anyone please comment out in the code that exactly what is hapenning in the each line of the code , what varibale is declared for what… It will really help me

anyone any TA please??

anyone available here??

Hi Akshat,
give me 5 mins. let me check ur code

Hi Akshat,
if u yourself have written the code then u must be knowing what is happening… if there is any issue then let me know…

no i haven’t written this myself i got i t from discuss forum…please help me out here

The logic behind this Problem was pretty simple as we can invert any digit ( 9 - digit) but we need to invert only such digits that will eventually end up giving the smallest number possible.

So, we should invert only digits greater then or equal to 5 as after inverting them, the result gives us smallest number.

For e.g.,

9 - 5 = 4 viz, smaller than the original number that was 5.

9 - 8 = 1 viz, smaller than the original number that was 8.

but 9 - 1 = 8 viz, greater than the original number that was 1.

Important point to consider is, After inverting any digits their should not be trailing zeros that means, if their is 9 at the starting of the number then it must remain the same

refer this --> https://ide.codingblocks.com/s/623839

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.