Seyed has 998 white coins, a red coin, and an unusual coin with one red side and one white side. He can not see the color of the coins instead he has a scanner which checks if all of the coin sides touching the scanner glass are white. Is there any algorithm to find the red coin by using the scanner at most 17 times? Proposed by Seyed Reza Hosseini
Problem
Source: Iranian Combinatorics Olympiad 2020 P7
Tags: combinatorics, coins
27.04.2020 21:11
We claim that the answer is YES. First, define $f(n)$ be the least number of scans Seyed needs to determine the red coin out of one red coin, one red-white coin and $n-2$ white coins. We will let $f(1)=0$ because we assume that the pile always has at least one red coin. The main claim, then, is this: If $m$ and $n$ are positive integers, then $$f(m+2n)\leq{\max\big(f(n)+3, f(m)+2, \lceil\log_2{n}\rceil + 3}\big)$$ To see why, first divide the pile of $k$ in one pile of $m$ and two piles of $n$. Then scan the pile of $m$ coins. If the scanner says "yes", then pick a pile of $n$ coins that scan that pile, then flip all the coins in that pile over and scan it again. If the scanner says "no" both times, then the red coin must be in that pile, but if it says "yes" at least once, then the red coin must be in the other pile of $n$ coins. Either way, we've reduced our search down to $n$ coins and it took three scans, leading to a total of $f(n)+3$ in this case. If the scanner says "no" to the pile of $m$ coins, then flip all the coins in that over and scan it again. If it still says "no", then the red coin must be in that pile, so we've reduced our search to $m$ coins and it took two scans, leading to a total of $f(m)+2$ in this case. If the scanner says "no" to the pile of $m$ coins, but it says "yes" when we flip all the coins over, this means that the red-white is in that pile but NOT the red coin. So we can discard that pile and we are left with $2n$ coins. However, since there is no red-white coin, then Seyed can then eliminate half of coins (rounded down if it's odd) with each scan by splitting the remaining possible candidates into two piles of roughly the same size and scanning one of them; if the scanner says "yes", then it must be in the other pile and if it says "no", then it must be in that pile. One can prove with an easy induction that it is $\lceil\log_2{2n}\rceil$, and it took two moves to get here, leading to a total of $\lceil\log_2{2n}\rceil+2$, or $\lceil\log_2{n}\rceil+3$ in this case. The worst-case scenario is just the highest of these quantities, which then proves the claim.
It's a good exercise if you want to figure it out yourself. Here's what I'm wondering though: can he do it in 16 moves? And what is the explicit formula for $f$?
28.04.2020 09:49
AforApple wrote: Here's what I'm wondering though: can he do it in 16 moves? And what is the explicit formula for $f$? Yes, It can be done in 16 steps. It can be proved that you can find the red coin among $F_n$ coins in $n$ steps. $F_1=1, F_2=2, \text{ and } F_n=F_{n-1}+F_{n-2}$
03.05.2020 22:35
Lemma 1: Consider the Fibonacci sequence. For each integer $n\geq 2$: \begin{align*} F_n \leq 2^{n-2} \end{align*} Proof: We proceed it by induction. For the case $n=2$, $F_2 =1 \leq 2^{2-2}=0$. And the induction step is true from: \begin{align*} F_{n+1}=F_n +F_{n-1} \leq 2F_n \leq 2.2^{n-2}=2^{n-1} \end{align*}Hence the lemma is true for all integers greater than 1.$\blacksquare$ Lemma 2: We can find the red coin from $n$ coins consisting of a red and $n-1$ white coins in at most $\lceil log_2 n\rceil$ steps. Proof: We proceed by induction. The case $n=1$ is trivial. Assume that the induction hypothesis is fulfilled for $i=1,2,\dots n-1$. We prove that it is true for $n$ as well. We take $\lfloor \frac{n}{2} \rfloor$ of the coins and put them in the scanner. From the answer we find out that the red coin is among these coins or in the other coins. By using the induction hypothesis we can find the red coin in at most $\lceil log_2(\lfloor \frac{n}{2}\rfloor)\rceil+ 1 \leq \lceil log_2 n \rceil $ steps.$\blacksquare$ Back to the main problem, we want to prove that we can find the red coin among any group of $k<F_n$ coins including an unusual coin by using the scanner at most $n$ times. Again we use induction. For $n=1$ and $n=2$ we can find the red coin by using the scanner at most 1 and 2 times, respectively. Assume that for each $i$ between 3 and $n-1$ we can find the red coin among $F_i$ coins including an unusual coin by using the scanner at most $i$ times. Now we take $F_n$ coins and partition the in two groups $A$ and $B$ with $F_{n-1}$ and $F_{n-2}$ coins, respectively. The we scan group $B$. We have the following two cases: 1- There is no red side. It means that the red coin is in group $A$. Thus from the induction hypothesis, we can find it in at most $n-1$ steps. 2- There is a red side. In this case, we reverse the coins in the scanner and scan them again. We have the following cases: A)There is a red side. It means that the red coin is in this group. By induction hypothesis we can find the red coin in at most $n-2$ steps. B)There is no red side. it means that group $A$ has $F_{n-1}-1$ white coins and one red coin. By using the first lemma we have $F_{n-2}\leq2^{n-2}$. Thus we can find the red coin by using lemma 2 with at most $n-2$ steps.