I didn’t get what the Chewbacca and number Problem is trying to say. Can you please provide some more examples and explanations for this problem, please???
I didn't get what the Chewbacca and number Problem is trying to say. Can you please provide some more example and explanation to this problem please?
in this question u need to generate minimum number from given number by flipping digits of the given number.(i,e if digit is t then u can flip it with 9-t
note : the generate number should not have leading 0’s
for example -> if n = 987 then u cannot replace 9 with 0 becuase then it will give leading 0.
the idea is read the given number as string (say s) .
if left most character is ‘9’
then leave the leftmost character as it is and for other characters simpl replace s[i] with min(s[i],‘9’-s[i])
else:
for each i replace s[i] with min(s[i],‘9’-s[i])
print s