<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[Chaos at the Sky]]></provider_name><provider_url><![CDATA[https://chaosatthesky.wordpress.com]]></provider_url><author_name><![CDATA[chaotic_iak]]></author_name><author_url><![CDATA[https://chaosatthesky.wordpress.com/author/chaoticiak/]]></author_url><title><![CDATA[The Genius, by A Skymin&#8217;s Mind&nbsp;#5]]></title><type><![CDATA[link]]></type><html><![CDATA[<h1>Truth Detector</h1>
<p>Used as Season 2 Final Game, Round 2.</p>
<p><b>Rules</b></p>
<p>There are two players. Each player prepares a 4-digit password and tries to hide it from his opponent. Then each player, in turn, can start asking questions to each other, which must be answered <em>untruthfully</em>. In other words, if you ask &#8220;How many times the digit 0 appears in your code?&#8221; and you receive a reply of 0, it means there exists the digit 0 in the code (because the reply is wrong). However, this reply cannot be an impossible reply (such as an answer of &#8220;5&#8221; for the above, considering that there are only 4 digits) or an unrelated/evasive reply (such as &#8220;I don&#8217;t know&#8221;). Additionally, questions must only be about the password. When giving a truth or any of the forbidden replies above, the penalty is revealing a digit not in the password.</p>
<p>When one thinks he knows the password of the other, he may use the turn to answer instead, guessing the password. If this is correct, he is the winner; if this is incorrect, the turn passes to the opponent.</p>
<p>As this is a Final Game, there are three items given:</p>
<ul>
<li>Starting Player: The person with this item may start asking question first.</li>
<li>Truth Penalty Exemption: If a person accidentally answers the truth, using this item he may avoid the penalty once.</li>
<li>Double Turn: This item may be used to give an additional turn, be it for asking or guessing.</li>
</ul>
<p><!--more--></p>
<p><b>Strategy</b></p>
<p>Let&#8217;s first go &#8220;innocent&#8221;. Suppose we ask a question with <img src="https://s0.wp.com/latex.php?latex=x&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=x&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=x&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="x" class="latex" /> options. Then whatever option the opponent replies, it is not that. Clearly the opponent should choose the option that rules out the least possibilities. Suppose that we aren&#8217;t lucky; if the option that has the least possibilities is option A, then the opponent apparently responds by A (so the password is not in A). Then we reduce the number of possibilities into at least <img src="https://s0.wp.com/latex.php?latex=%5Cdfrac%7Bx-1%7D%7Bx%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=%5Cdfrac%7Bx-1%7D%7Bx%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=%5Cdfrac%7Bx-1%7D%7Bx%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="&#92;dfrac{x-1}{x}" class="latex" /> of the original. To make the best use of this, of course <img src="https://s0.wp.com/latex.php?latex=x+%3D+2&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=x+%3D+2&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=x+%3D+2&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="x = 2" class="latex" /> so we halve the number of choices. With the correct question, we can make sure both cases have the same number of choices and thus the number of possibilities is cut as fast as possible. This is also known as binary search.</p>
<p>Since there are 10000 possibilities and this number is halved each turn, we need at least 14 turns to complete. This is easy to achieve; for example, &#8220;is your number bigger than 5000?&#8221;, then &#8220;is your number bigger than 2500/7500?&#8221;, then &#8220;is your number bigger than 1250/3750/6250/8750?&#8221;, and so on. Sangmin&#8217;s strategy is a slightly inefficient one at 16 turns (&#8220;even/odd?&#8221;, followed by 3-turn binary search, for each of the 4 digits), but is easier to keep track.</p>
<p>That&#8217;s the simple strategy. What approaches can help?</p>
<p>I have two strategies in mind, the second of which abuses the rules quite heavily, and given that I don&#8217;t know the exact rules, this might be unplayable. So let&#8217;s begin with the easier strategy first.</p>
<p>This strategy relies on the difficulty of answering some questions. For example, &#8220;if your number is divided by 256, is the remainder less than 128?&#8221; is a difficult question, which nevertheless splits the possibilities into two rather-equally-sized clumps. Indeed, the strategy is to reconstruct the binary representation of the number. On the <img src="https://s0.wp.com/latex.php?latex=i&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=i&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=i&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="i" class="latex" />-th question, ask &#8220;if your number is divided by <img src="https://s0.wp.com/latex.php?latex=2%5Ei&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=2%5Ei&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=2%5Ei&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="2^i" class="latex" />, is the remainder less than <img src="https://s0.wp.com/latex.php?latex=2%5E%7Bi-1%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=2%5E%7Bi-1%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=2%5E%7Bi-1%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="2^{i-1}" class="latex" />?&#8221; This is basically asking what the <img src="https://s0.wp.com/latex.php?latex=i&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=i&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=i&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="i" class="latex" />-th digit from the right is in the password&#8217;s binary representation. For example, if my password is <img src="https://s0.wp.com/latex.php?latex=0492&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=0492&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=0492&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="0492" class="latex" />, then its binary representation is <img src="https://s0.wp.com/latex.php?latex=00000111101100_2&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=00000111101100_2&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=00000111101100_2&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="00000111101100_2" class="latex" />, and thus I will respond with &#8220;no, no, yes, yes, no, yes, &#8230;&#8221; to the questions. Due to how we phrase the question, if we take yes = 1 and no = 0, this is a truthful reconstruction of the number. And since things get heavy to compute at the later questions, it&#8217;s very likely that we will get some slip from the opponent, giving us one digit to rule out and potentially cutting some of the possibilities, making 12-13 turns of questioning (+1 to answer) possible. (For example, <img src="https://s0.wp.com/latex.php?latex=10000111101100_2+%3D+8684&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=10000111101100_2+%3D+8684&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=10000111101100_2+%3D+8684&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="10000111101100_2 = 8684" class="latex" />; if I answered incorrectly on some question above and gave the digit 8, then you would know without the 14th question that my number is <img src="https://s0.wp.com/latex.php?latex=0492&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=0492&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=0492&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="0492" class="latex" /> and not <img src="https://s0.wp.com/latex.php?latex=8684&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=8684&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=8684&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="8684" class="latex" />.)</p>
<p>The second strategy is abusing the rules. What if our question has only one answer (&#8220;Does your password have 4 digits?&#8221;, for example)? Then answering truthfully means the opponent gives one digit to us, and answering untruthfully means giving an impossible reply, which also means the opponent gives one digit to us. The rules get unclear here; what happens if the opponent gets more than one penalty? Does he need to give different digits each time or not? If he needs to give different digits, what happens if he exhausted all digits not in the password? Here, I assume that different digits must be given, but if all digits have been exhausted, then we are simply notified of such.</p>
<p>Moreover, if we have ruled out a particular option (for example, &#8220;is your password 0000?&#8221; is answered yes), then can the opponent gives a reply that isn&#8217;t consistent with the remaining options (for example, &#8220;how many digits 0 are in your password?&#8221; is answered 4)? Here, we assume the opponent is allowed to do so, so we need to construct our questions carefully.</p>
<p>Then things get interesting.</p>
<p>If we only remove one digit at a time, the first digit removed, our possibilities reduce from <img src="https://s0.wp.com/latex.php?latex=10%5E4+%3D+10000&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=10%5E4+%3D+10000&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=10%5E4+%3D+10000&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="10^4 = 10000" class="latex" /> to <img src="https://s0.wp.com/latex.php?latex=9%5E4+%3D+6561&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=9%5E4+%3D+6561&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=9%5E4+%3D+6561&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="9^4 = 6561" class="latex" />. This is not quite a nice drop, only 1/3 or so removed. We still fare better by using binary search (to 5000). We can continue cutting down to <img src="https://s0.wp.com/latex.php?latex=8%5E4+%3D+4096%2C+7%5E4+%3D+2401%2C+6%5E4+%3D+1296%2C+5%5E4+%3D+625&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=8%5E4+%3D+4096%2C+7%5E4+%3D+2401%2C+6%5E4+%3D+1296%2C+5%5E4+%3D+625&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=8%5E4+%3D+4096%2C+7%5E4+%3D+2401%2C+6%5E4+%3D+1296%2C+5%5E4+%3D+625&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="8^4 = 4096, 7^4 = 2401, 6^4 = 1296, 5^4 = 625" class="latex" />&#8230;oh hey, now we&#8217;re doing better than binary search! But with 5 questions, binary search from the beginning yields a nice <img src="https://s0.wp.com/latex.php?latex=313&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=313&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=313&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="313" class="latex" /> possibilities remaining here. So we go lower to <img src="https://s0.wp.com/latex.php?latex=4%5E4+%3D+256&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=4%5E4+%3D+256&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=4%5E4+%3D+256&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="4^4 = 256" class="latex" /> versus <img src="https://s0.wp.com/latex.php?latex=157&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=157&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=157&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="157" class="latex" />, then go lower&#8230;wait, now the opponent might have no more digit to remove. If we&#8217;re lucky, the opponent holds four different digits, and after being notified of such, our possibilities take a massive drop to <img src="https://s0.wp.com/latex.php?latex=4%21+%3D+24&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=4%21+%3D+24&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=4%21+%3D+24&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="4! = 24" class="latex" /> versus <img src="https://s0.wp.com/latex.php?latex=79&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=79&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=79&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="79" class="latex" />, faring better than binary search! If we&#8217;re unlucky, now we&#8217;re left with <img src="https://s0.wp.com/latex.php?latex=3%5E4+%3D+81&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=3%5E4+%3D+81&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=3%5E4+%3D+81&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="3^4 = 81" class="latex" /> versus <img src="https://s0.wp.com/latex.php?latex=79&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=79&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=79&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="79" class="latex" />, but we&#8217;re closing up!</p>
<p>Next, if the opponent holds three distinct digits, then we&#8217;re stuck here, having <img src="https://s0.wp.com/latex.php?latex=3+%5Ccdot+4+%5Ccdot+3+%3D+36&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=3+%5Ccdot+4+%5Ccdot+3+%3D+36&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=3+%5Ccdot+4+%5Ccdot+3+%3D+36&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="3 &#92;cdot 4 &#92;cdot 3 = 36" class="latex" /> versus <img src="https://s0.wp.com/latex.php?latex=40&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=40&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=40&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="40" class="latex" /> possibilities remaining. (3 for the digit repeated, 4 for the location of the smaller non-repeated digit, and 3 for the location of the larger non-repeated digit.) But we&#8217;re doing (slightly) better already. If we&#8217;re lucky, we might be left with only two digits, <img src="https://s0.wp.com/latex.php?latex=2%5E4+%3D+16&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=2%5E4+%3D+16&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=2%5E4+%3D+16&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="2^4 = 16" class="latex" /> versus <img src="https://s0.wp.com/latex.php?latex=40&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=40&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=40&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="40" class="latex" />, where we can just continue with binary search.</p>
<p>Let&#8217;s compare the possibilities.</p>
<ul>
<li>Four different digits: We take 6 questions to remove digits and 1 more question to know that we&#8217;re done removing digits. This means 7 questions. With <img src="https://s0.wp.com/latex.php?latex=4%21+%3D+24&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=4%21+%3D+24&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=4%21+%3D+24&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="4! = 24" class="latex" /> possibilities left, binary search solves this in 5 questions, so that&#8217;s a total of 12 questions.</li>
<li>Three different digits: We take 7 questions to remove digits and 1 more question to know that we&#8217;re done removing digits. This means 8 questions. With <img src="https://s0.wp.com/latex.php?latex=3+%5Ccdot+4+%5Ccdot+3+%3D+36&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=3+%5Ccdot+4+%5Ccdot+3+%3D+36&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=3+%5Ccdot+4+%5Ccdot+3+%3D+36&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="3 &#92;cdot 4 &#92;cdot 3 = 36" class="latex" /> possibilities left, binary search solves this in 6 questions, so that&#8217;s a total of 14 questions.</li>
<li>Two or one different digit: We take 8 questions to remove digits. With <img src="https://s0.wp.com/latex.php?latex=2%5E4+%3D+16&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" srcset="https://s0.wp.com/latex.php?latex=2%5E4+%3D+16&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002 1x, https://s0.wp.com/latex.php?latex=2%5E4+%3D+16&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002&#038;zoom=4.5 4x" alt="2^4 = 16" class="latex" /> possibilities left, binary search solves this in 4 questions, so that&#8217;s a total of 12 questions.</li>
</ul>
<p>So, hey, that&#8217;s an awesome combination. We fare generally better than binary search, considering that binary search takes 13-14 turns and ours take 12-14 turns. Expected value and such tells that binary search takes about 13.28771 turns while the above strategy takes about 12.29623 turns. (Try computing it yourself.) That&#8217;s one whole turn saved!</p>
<p>Of course, due to there being plenty of rules not revealed, I can&#8217;t be sure whether that strategy is allowed, or whether there&#8217;s an even better strategy. But that suffices. Safe to say Yohwan was pretty stupid with his sum and product thingies.</p>
]]></html></oembed>