How to solve this puzzle by invariance principle?

377 Views Asked by At

I have the following puzzle-

You initially have $15$ $\color{red}{\text{red}}$ and $12$ $\color{brown}{\text{yellow}}$ balls.You can do one of the two things with the balls-

  1. $\text{Swap}-$You can swap the balls.This means if you start with $x$ red and $y$ yellow balls,after the transformation you have $y$ red and $x$ yellow balls.

  2. $\text{Exchange}-$You can exchange $3$ red balls for $2$ yellow balls provided that you have atleast $3$ red balls.

    • Now,if possible after how many transformations (you can use either of the rules mentioned above as $1$ or $2$ any number of times and in any order) will you have $5$ red balls and $5$ yellow balls?

    • Also,what is the total number of combination of the number of balls you can have?

How to solve this with invariance preferably.If not possible other methods are welcome too!

Thanks!!

1

There are 1 best solutions below

0
On

After each exchange the parity between red and yellow changes (from same parity to different parity, and vice versa). Moreover, each exchange reduces the total number of balls by $1$.

At the start, we have $27$ balls and different parities. If the final state has a total of $k$ balls, we will need to remove a total of $27-k$ balls; in other words, we will need to perform $27-k$ exchanges. If a state has $k$ balls, with $k_r$ red balls and $k_y$ yellow, then at the end one of the following must hold

  • $k$ is even $\iff$ $27-k$ is odd $\implies$ $k_r$ and $k_y$ are the same parity
  • $k$ is odd $\iff$ $27-k$ is even $\implies$ $k_r$ and $k_y$ are different parities

Now, if $k_r$ and $k_y$ satisfy the above relations, is the final state achievable?

Observe that a state $(k_r,k_y)$ is reachable if and only if the state $(k_y,k_r)$ is reachable, so it's fair to assume without loss of generality that $k_r\geq k_y$. For any given configuration, let $d=k_r-k_y$, so that in the beginning we have $d=3$.

An exchange makes $d\mapsto d-5$ and a swap makes $d\mapsto -d$. In particular, $d\pmod5$ is either $3$ or $-3\equiv 2$, so it can never be $0$. The state with $k_r=k_y=5$ is hence not reachable.