Number of guesses to find minimum arrangement

29 Views Asked by At

I apologize that the title is poorly worded, I don't know a good way to phrase it. Presumably, this problem has been researched before, I just can't find the right words to find any existing solution.

The motivation of this problem came from a situation I was in the other day. I had to set the permissions of someone else's account in such away that they had enough permissions to do what they needed to do, but not too many that they could do extraneous things, simply because it's a security issue if someone else gains access to the account.

Mathematically:

Consider an $n$-digit binary number that you have to guess. After each of your guesses, you get one piece of feedback: Either all of the $1$s in the number are covered, or they aren't. For example, say the number you are trying to guess is $10110$. For your first guess, you pick $10100$. In this case, not all the $1$s are covered (the 4th digit is wrong). Next, you guess $10111$. In this case, it tells you that all the $1$s are covered (it doesn't matter that you have an extraneous $1$ in the 5th digit).

What makes it tricky is that the feedback doesn't differentiate between "right answer" and "too many $1$s," and also that it could very from every digit being a $1$ to no digits being a $1$. My question is, what is the optimal set of guesses?

(Also would appreciate help with appropriate tags)

1

There are 1 best solutions below

0
On

To expand on InstellarProbe's comments: if the number is $1^n$ then you need at least $n$ tests to confirm that, so the sequential strategy guessing $g_1,g_2,\ldots,g_n$, where $g_i=1^{i-1}01^{n-i}$ is optimal.

If you have more information about the number you can do better. Consider for example the following strategy: if guess $g_{12}=001^{n-2}$ covers, the prefix is $00$. Otherwise, if guess $g_1$ covers, the prefix is $01$. Otherwise, if guess $g_2$ covers the prefix is $10$, else $11$. For positions $(3,4), (5,6), \ldots$ repeat the same strategy.

In the worst case this takes about $3n/2$ guesses. But if you know that the probability of any position having a $1$ is $p$, then the expected number of guesses for each pair of positions is $G=q^2+2qp+3(qp+p^2)$ where $q=1-p$, and so the total number is about $nG/2$. So for $G<2$ the expected number of guesses for this strategy is better than the sequential strategy. This is the case for $p<(3-\sqrt 5)/2\approx 0.38$.