I wondered what can be the pre final stage cases for this problem, so I assumed an initial number of x,y, and z for each type of chameleon and assumed that everyone converts to the z type. So in my version of a pre final stage (assuming pairing of x-y chameleons until one of the types is exhausted), we would be left with (x-y) or (y-x) number of single coloured chameleons depending upon what's positive. Then, by taking examples for 1,2,3 to be the number at pre final stage, one can figure out the pattern that the pre final stage number should be divisible by 3.
This is correct. One solution goes this way - (r-b) or (b-r) mod 3 remains invariant, if we just do operations to create green chameleons. This should be zero, but if it isn't for the initial given conditions, you get a proof that you cannot do that.
A general formulation, which you can try to understand now is:
Any (r, b, y) - configuration is reducible to a single color configuration if and only if at least two of the quantities r, b, y have the same remainder of division by 3.
Well I used one method, correct me if i am wrong, taking 3 chameleons case, and we have to convert them to red, so converting them to Red until one color has 0 chameleons left, as asked in above problem (28,0,2). Then the other color left i.e. blue color, will be reduced by 3 (taking 1 of red and 1 of blue changing them to green, then taking 1 blue and 1 green to convert them to Red, doing this twice), doing this it will give (27,2,1), then (29,1,0) and we can continue no further, so the remaining color should be a multiple of 3(or mod%3=0) to be able to convert all chameleons to Red or any other color.
Yes, this is correct. You manually put the value of n as 1 two times and then used the mod operator. It is equivalent to our above method - just that this is hit and trial and would be easier to strike while handling an interview, and ours gave a more fundamental approach to tackling it.
I wondered what can be the pre final stage cases for this problem, so I assumed an initial number of x,y, and z for each type of chameleon and assumed that everyone converts to the z type. So in my version of a pre final stage (assuming pairing of x-y chameleons until one of the types is exhausted), we would be left with (x-y) or (y-x) number of single coloured chameleons depending upon what's positive. Then, by taking examples for 1,2,3 to be the number at pre final stage, one can figure out the pattern that the pre final stage number should be divisible by 3.
This is correct. One solution goes this way - (r-b) or (b-r) mod 3 remains invariant, if we just do operations to create green chameleons. This should be zero, but if it isn't for the initial given conditions, you get a proof that you cannot do that.
A general formulation, which you can try to understand now is:
Any (r, b, y) - configuration is reducible to a single color configuration if and only if at least two of the quantities r, b, y have the same remainder of division by 3.
Elegant!
Well I used one method, correct me if i am wrong, taking 3 chameleons case, and we have to convert them to red, so converting them to Red until one color has 0 chameleons left, as asked in above problem (28,0,2). Then the other color left i.e. blue color, will be reduced by 3 (taking 1 of red and 1 of blue changing them to green, then taking 1 blue and 1 green to convert them to Red, doing this twice), doing this it will give (27,2,1), then (29,1,0) and we can continue no further, so the remaining color should be a multiple of 3(or mod%3=0) to be able to convert all chameleons to Red or any other color.
Yes, this is correct. You manually put the value of n as 1 two times and then used the mod operator. It is equivalent to our above method - just that this is hit and trial and would be easier to strike while handling an interview, and ours gave a more fundamental approach to tackling it.