<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>4by12 &#187; Riddles</title>
	<atom:link href="http://4by12.com/blog/archives/category/riddles/feed" rel="self" type="application/rss+xml" />
	<link>http://4by12.com/blog</link>
	<description>by Guy Gur-Ari</description>
	<lastBuildDate>Sat, 21 Aug 2010 00:01:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Prisoners&#8217; Escape &#8211; The Solution</title>
		<link>http://4by12.com/blog/archives/106</link>
		<comments>http://4by12.com/blog/archives/106#comments</comments>
		<pubDate>Mon, 13 Aug 2007 09:30:14 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/archives/106</guid>
		<description><![CDATA[(you can find the original riddle here) Let&#8217;s begin with a draft solution, one that doesn&#8217;t work but will start us in the right direction. And to keep things simple, let&#8217;s say all the tasks are done the minute the prisoners leave the meeting, so all they have left is to notify someone that they&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>(you can find the original riddle <a href="/blog/archives/105">here</a>)</p>
<p>Let&#8217;s begin with a draft solution, one that doesn&#8217;t work but will start us in the right direction. And to keep things simple, let&#8217;s say all the tasks are done the minute the prisoners leave the meeting, so all they have left is to notify someone that they&#8217;re done.</p>
<p>Prisoner 1 is responsible for telling the guard once all the tasks are complete. We&#8217;ll call him the Leader. He keeps a counter called &#8216;<code>num_done</code>&#8216; which starts at 1 (denoting that prisoner 1 himself is done). When the leader enters the room, this is what he does:</p>
<pre>
if light is on:
    num_done = num_done + 1
    turn light off
else:
    do nothing
-
</pre>
<p>When any other prisoner enters the room, this is what he does:</p>
<pre>
if light is off and not turned_light_on:
    turn light on
    turned_light_on = true
else:
    do nothing
-
</pre>
<p>And each such prisoner maintains a flag called <code>turned_light_on</code>, initialized to &#8216;false&#8217;.</p>
<p>At the end of this, <code>num_done</code> should show the number of prisoners whose task is complete. And when <code>num_done = n</code>, prisoner 1 will notify the guard.</p>
<p>The problem is that this algorithm has an off-by-one error. If the light was originally on before any prisoner entered the room, then when the leader enters the room he will count that on-light as one prisoner. Therefore he&#8217;ll reach a count of n while only (n-1) prisoners reported in.</p>
<p>To solve this problem we need to modify the algorithm a bit, to handle the possible initial states of the light switch. We want to give the leader a chance to see the initial state before anyone else touches it. So the other prisoners start by doing nothing, until they get some sort of signal from the leader. This signal will be &#8216;flicking the switch&#8217;: They first want to see the light turned on, and then, when the time is right, they will turn it on themselves.</p>
<p>So now, each prisoner <i>other than</i> the leader maintains another flag called <code>saw_light_on</code>, which starts as &#8216;false&#8217;. The algorithm is:</p>
<pre>
if light is on:
    saw_light_on = true
else if saw_light_on and not turned_light_on:
    // light is OFF
    turn light on
    turned_light_on = true
else:
    do nothing
-
</pre>
<p>Next, the leader maintains an extra flag: <code>saw_initial_state</code> initialized to &#8216;false&#8217;. Her algorithm is:</p>
<pre>
if saw_initial_state:
	if light is on:
	    turn light off
	    num_done = num_done + 1
	else
	    // flick the switch to signal the others
	    turn light on
	    num_done = num_done - 1
else:
	// This is the first time the leader enters the room
	turn light off (if it's on)
	saw_initial_state = true
-
</pre>
<p>Note that the leader needs to continue flicking the switch forever. Otherwise, latecomers will never turn the light on. Also note that the leader must discount for his own flicking by decrementing <code>num_done</code>. Finally, as before, when <code>num_done = n</code>, the leader notifies the guard and the prisoners escape. There you have it!</p>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/106/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prisoners&#8217; Escape</title>
		<link>http://4by12.com/blog/archives/105</link>
		<comments>http://4by12.com/blog/archives/105#comments</comments>
		<pubDate>Wed, 01 Aug 2007 18:53:04 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/archives/105</guid>
		<description><![CDATA[In an effort to make this blog more interactive, I&#8217;m switching the riddles to a new format. I&#8217;ll first post only the riddle, without the solution, so you guys can have a crack it. After a week or so, I&#8217;ll post the solution. Here goes&#8230; prisoners are planning an escape. They bribed a guard to [...]]]></description>
			<content:encoded><![CDATA[<p>In an effort to make this blog more interactive, I&#8217;m switching the riddles to a new format. I&#8217;ll first post only the riddle, without the solution, so you guys can have a crack it. After a week or so, I&#8217;ll post the solution. Here goes&#8230;</p>
<p><img src='/latexrender/pictures/7b8b965ad4bca0e41ab51de7b31363a1.png' title='n' alt='n' align=absmiddle> prisoners are planning an escape. They bribed a guard to let them all meet once. Each prisoner was given a task to complete, such as digging or stealing some key. Once all the tasks are complete, the prisoners will notify the corrupt guard who will turn a blind eye while they escape. The problem is, the prisoners can&#8217;t talk to each other because they are all in solitary confinement. </p>
<p>Once a day, a prisoner chosen at random enters a storage room that has a single light bulb in it. The prisoner can either flick the switch (turning the light bulb on or off), or leave it as it is. At the time of the initial meeting, as they plan their strategy, the state of the switch is unknown. </p>
<p>Using only switch flicking, how can the prisoners coordinate their escape? Specifically, one of the prisoners must know at some point that all the tasks are done, so he can notify the guard and lead them all to freedom. If the guard is notified before all tasks are complete, the plan will fail and the prisoners will be caught.</p>
<p>(ready for the solution? <a href="/blog/archives/106">here it is</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/105/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chicken McNuggets</title>
		<link>http://4by12.com/blog/archives/59</link>
		<comments>http://4by12.com/blog/archives/59#comments</comments>
		<pubDate>Mon, 07 Aug 2006 13:13:06 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/archives/59</guid>
		<description><![CDATA[McDonald&#8217;s sells its Chicken McNuggets in groups of 6, 9, and 20. What is the largest number of McNuggets you can&#8217;t buy? Solution: I&#8217;m sure there&#8217;s a simpler solution to this, but here goes. Let , which is an amount we can buy using only boxes of 6 nuggets. Let&#8217;s see how we can &#8216;fill [...]]]></description>
			<content:encoded><![CDATA[<p>McDonald&#8217;s sells its Chicken McNuggets in groups of 6, 9, and 20. What is the largest number of McNuggets you <em>can&#8217;t</em> buy?</p>
<p><span id="more-59"></span></p>
<p>
<strong>Solution:</strong> I&#8217;m sure there&#8217;s a simpler solution to this, but here goes. Let <img src='/latexrender/pictures/d38008dd82e6fefb75c1c44e62e14cff.png' title='x_n=6n' alt='x_n=6n' align=absmiddle>, which is an amount we can buy using only boxes of 6 nuggets. Let&#8217;s see how we can &#8216;fill in the gaps&#8217; between two consecutive <img src='/latexrender/pictures/5bef92b1854f9c388d11bfbb1720c05d.png' title='x_n' alt='x_n' align=absmiddle>, <img src='/latexrender/pictures/f53241bca9ab95ed510049ebcd7cfbe7.png' title='x_{n+1}' alt='x_{n+1}' align=absmiddle> by removing some 6&#8242;s and replacing them with 9&#8242;s and 20&#8242;s:
</p>
<ul>
<li><img src='/latexrender/pictures/399ee3933f8969e0d3fa9a63f2cf49d7.png' title='x_n-3*6+20=x_n+2' alt='x_n-3*6+20=x_n+2' align=absmiddle> (condition: n>=3)</li>
<li><img src='/latexrender/pictures/4695416124ae2bfbce5dc74e4963636e.png' title='x_n-6+9=x_n+3' alt='x_n-6+9=x_n+3' align=absmiddle> (n>=1)</li>
<li><img src='/latexrender/pictures/c8c02a21ece18a2aba6931571f6619c1.png' title='x_n+2*(-3*6+20)=x_n+4' alt='x_n+2*(-3*6+20)=x_n+4' align=absmiddle> (n>=6)</li>
<li><img src='/latexrender/pictures/582657252b56d8edf4e3af91ec556cb4.png' title='x_n+(-3*6+20)+(-6+9)=x_n+5' alt='x_n+(-3*6+20)+(-6+9)=x_n+5' align=absmiddle> (n>=4)</li>
<li><img src='/latexrender/pictures/5b59f321b115a86491b831ca7f87ed77.png' title='x_n+2*(-3*6+20)+(-6+9)-6=x_n+1' alt='x_n+2*(-3*6+20)+(-6+9)-6=x_n+1' align=absmiddle> (n>=8)</li>
</ul>
<p>
Note that only the first two options are original &#8212; the rest are simply combinations of the first two. So, if n is large enough (n >= 8 ), we can fill in all the gaps between <img src='/latexrender/pictures/5bef92b1854f9c388d11bfbb1720c05d.png' title='x_n' alt='x_n' align=absmiddle> and <img src='/latexrender/pictures/f53241bca9ab95ed510049ebcd7cfbe7.png' title='x_{n+1}' alt='x_{n+1}' align=absmiddle> by removing some boxes of 6 nuggets, and replacing them with various combinations of 9 and 20 nuggets.
</p>
<p>
This means that, starting with <img src='/latexrender/pictures/93a76ff4c983133475fbd636c23f220c.png' title='x_8=6*8=48' alt='x_8=6*8=48' align=absmiddle>, we can buy any number of nuggets. What about the numbers between <img src='/latexrender/pictures/0433d33c9d8fc40ef6539a976a6f8c0e.png' title='x_7=42' alt='x_7=42' align=absmiddle> and <img src='/latexrender/pictures/fcb9a315977309c4195e3550cbd180a7.png' title='x_8=48' alt='x_8=48' align=absmiddle>? According to the list above, given n=7 we can create all the numbers in this range except, perhaps, <img src='/latexrender/pictures/25eabba4676a0a9a7ef6086de0cf18ae.png' title='x_7+1=43' alt='x_7+1=43' align=absmiddle>.
</p>
<p>
It&#8217;s easy to see that there&#8217;s indeed no way to buy 43 nuggets: 43 itself isn&#8217;t divisable by 3, so you can&#8217;t get 43 with a combination of 6&#8242;s and 9&#8242;s. So you must use either one or two boxes of 20. But 43-20=23 is again not divisable by 3, and 43-20*2=3 is less than 6.
</p>
<p>
Hence, 43 is the largest amount of nuggets you can&#8217;t buy at McDonald&#8217;s.</p>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/59/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Four Cups</title>
		<link>http://4by12.com/blog/archives/33</link>
		<comments>http://4by12.com/blog/archives/33#comments</comments>
		<pubDate>Fri, 07 Jul 2006 22:27:29 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/archives/33</guid>
		<description><![CDATA[Four coins are placed on a round table, in positions north, east, south, and west. The room is dark, so you can&#8217;t see the coins. Your goal is to get all coins to be on the same side &#8212; heads or tails. In each turn you can choose to flip any of the four coins. [...]]]></description>
			<content:encoded><![CDATA[<p>Four coins are placed on a round table, in positions north, east, south, and west. The room is dark, so you can&#8217;t see the coins. Your goal is to get all coins to be on the same side &#8212; heads or tails. In each turn you can choose to flip any of the four coins. After the coins are flipped, the table is rotated randomly and the turn ends. Once all the coins lie on the same side, the game ends and you win.</p>
<p><span id="more-33"></span>
<p>This is one of my favorite riddles, because the solution actually uses some nice mathematical concepts.</p>
<p>We are looking for a solution that will work regardless of how the table is rotated after each flip we make. It will be nice if we can place all the possible table states into classes that aren&#8217;t affected by the rotation. That way we can develop an algorithm to progress through the states without worrying about the rotation at each turn.</p>
<p>Let&#8217;s define the following states:</p>
<ol>
<li><b>A:</b> All coins are the same (all heads or all tails) &#8211; in this case we win</li>
<li><b>B:</b> Two opposing coins are heads, and the other two are tails.</li>
<li><b>C:</b> Two adjoining coins are heads, and the other two are tails.</li>
<li><b>D:</b> One coin is different from the other three.</li>
</ol>
<p>The last three states are illustrated below.<br />
<br />
<img src="/blog/wp-content/uploads/2006/07/4cups.png"><br />
</br></p>
<p>It&#8217;s clear that if a state is in a given category, then any rotation of it remains in the same category. Formally we can say that these categories are <i>equivalence classes</i>, using the relation that connects two states iff one can be reached from the other via rotation.</p>
<p>Okay, so our goal is to transform a state of any class to class A. We notice that coin flips change some classes but not others:</p>
<ul>
<li>Flip two opposing coins: This changes a B state to A (i.e. we win), but doesn&#8217;t transform either a C state or a D state to a different class</li>
<li>Flip two adjoining coins: C -> B or A, and D doesn&#8217;t change</li>
<li>Flip one coin: D -> C or B or A</li>
</ul>
<p>The winning strategy is thus:</p>
<ol>
<li>Flip North, South</li>
<li>Flip North, East</li>
<li>Flip North, South</li>
<li>Flip North</li>
<li>Flip North, East</li>
<li>Flip North, South</li>
</ol>
<p>This works as follows:</p>
<ul>
<li>If we start out in class B, we win after step 1</li>
<li>If we start out in class C, we win after step 2 or 3</li>
<li>If we start out in class D, we win after step 4, 5, or 6</li>
</ul>
<p>The point here is that when we handle class B, we don&#8217;t change either C or D. When we handle C, we don&#8217;t change D. So there you have it &#8212; victory in just six steps!</p>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/33/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prime Numbers</title>
		<link>http://4by12.com/blog/archives/54</link>
		<comments>http://4by12.com/blog/archives/54#comments</comments>
		<pubDate>Thu, 29 Jun 2006 17:21:31 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Riddles]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/archives/54</guid>
		<description><![CDATA[Here&#8217;s a nice one. Show that, for any prime number p other than 2 and 5, there is a multiple of p that is written as a series of 1&#8242;s in decimal representation. For example, 111 is a multiple of 3, and 11 is a multiple of itself. Hint: Use the pigeonhole principle. The solution: [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a nice one. Show that, for any prime number p other than 2 and 5, there is a multiple of p that is written as a series of 1&#8242;s in decimal representation. For example, 111 is a multiple of 3, and 11 is a multiple of itself. <b>Hint:</b> Use the pigeonhole principle.</p>
<p><span id="more-54"></span></p>
<p><b>The solution:</b> First, let&#8217;s show that there&#8217;s a multiple of p that is written as a series of 1&#8242;s, followed by a series of 0&#8242;s (e.g. 1111000). Consider the set of numbers {1, 11, 111, 1111, &#8230;}. For each item, calculate its &#8216;modulu p&#8217;: {1 mod p, 11 mod p, &#8230;}. Each of these is an integer between 0 and p-1. Because the original set is infinite, it must therefore contain two different items that are the same mod p (pigeonhole principle). Let&#8217;s call them a and b and assume a>b. Then (a-b) is the desired number, because:<br /> (a-b mod p) = (a mod p) &#8211; (b mod p) = 0.</p>
<p>Okay, so for the prime p we have a number x that&#8217;s divisable by p, and:</p>
<p>x = 111&#8230;10&#8230;0 = 111&#8230;1 * 10^n</p>
<p>We can divide x by 10^n to get rid of the zeros and get y = x / 10^n = 111&#8230;1. y is still divisable by p because p isn&#8217;t 2 or 5.</p>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/54/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ants on a Stick</title>
		<link>http://4by12.com/blog/archives/26</link>
		<comments>http://4by12.com/blog/archives/26#comments</comments>
		<pubDate>Sun, 11 Jun 2006 22:51:11 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/archives/26</guid>
		<description><![CDATA[You have a 1 meter long stick and 100 ants. The ants are somehow distributed on the stick, and each ant moves either right or left at 1 meter/second. When two ants meet, they both instantaneously turn around and start walking in opposite directions, still at 1 meter/second. When an ant reaches the edge of [...]]]></description>
			<content:encoded><![CDATA[<p>You have a 1 meter long stick and 100 ants. The ants are somehow distributed on the stick, and each ant moves either right or left at 1 meter/second. When two ants meet, they both instantaneously turn around and start walking in opposite directions, still at 1 meter/second. When an ant reaches the edge of the stick, it falls off.</p>
<p>If you control the initial placement and movement directions of the ants, what is the longest an ant can remain on the stick?</p>
<p><span id="more-26"></span>The answer: An ant can stay on the stick for at most one second.</p>
<p>The given situation is that when two ants meet, they both turn around and start walking in opposite directions. But this is exactly the same as a situation where the ants never interact, so when they meet they just pass through one another and continue walking in their original directions.</p>
<p>An single ant will remain the longest on the stick if you place it at one edge of the stick and let it walk towards the other edge. This will take exactly 1 second. And because the ants are indepedent, this is also the answer for 100 ants.</p>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/26/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two Envelopes: Part 2</title>
		<link>http://4by12.com/blog/archives/23</link>
		<comments>http://4by12.com/blog/archives/23#comments</comments>
		<pubDate>Sun, 04 Jun 2006 00:21:31 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/archives/23</guid>
		<description><![CDATA[As promised, here&#8217;s another solution to the two envelopes riddle: First, choose a descending list of probabilities p(n). When you receive a number n, say &#8216;higher&#8217; with probability p(n) and &#8216;lower&#8217; otherwise. That&#8217;s the solution. Now let&#8217;s prove that it works. Say the other person chooses numbers n P(win) = 0.5*p(n) + 0.5*(1-p(m)) = 0.5*(1 [...]]]></description>
			<content:encoded><![CDATA[<p>As promised, here&#8217;s another solution to the <a href="http://4by12.com/blog/archives/15">two envelopes riddle</a>: First, choose a descending list of probabilities p(n). When you receive a number n, say &#8216;higher&#8217; with probability p(n) and &#8216;lower&#8217; otherwise. That&#8217;s the solution. Now let&#8217;s prove that it works.<span id="more-23"></span></p>
<p>Say the other person chooses numbers n</p>
<p>P(win) = 0.5*p(n) + 0.5*(1-p(m)) = 0.5*(1 + p(n) &#8211; p(m)) > 0.5</p>
<p>That last step is where I use the fact that the series of probabilities descends: n < m and so p(n) > p(m). Finally, because P(win) is larger than 0.5 for every n,m pair that can be chosen, we expect to win with probability greater than 0.5.</p>
<p>I&#8217;ll now explain how I found this solution, and that will shed some light on why it works in the first place. The explanation is a bit long and verbose, because I tried to make it as clear as possible. The first thing I noticed when thinking about the riddle is that, if the first number I get is 1, then the second number must be higher. So if I get 1, I can say &#8216;higher&#8217; and be correct every time. I then devised my first strategy: <em>If the number is 1, say &#8216;higher&#8217;. Otherwise say &#8216;higher&#8217; with probability 0.5.</em></p>
<p>If the other person has a chance of giving me 1, then I will obviously win in the long run. The other person knows my strategy, so he cannot ever give me 1. Okay, so the minimum number I get is 2&#8230; Maybe if I get 2 I can say &#8216;higher&#8217;, and be correct. And maybe I can follow this line of reasoning and do the same with 3, 4, 5, &#8230; ad infinitum. Well, this of course doesn&#8217;t work, because eventually the other person must choose some number and I won&#8217;t always be right.</p>
<p>So this strategy isn&#8217;t scalable, so to speak. But there is some knowledge here: The other person is less likely to choose 1 as one of the numbers, because then she has a 0.5 chance of giving it to me as the first number and letting me win. So if I get 2, I know that it is likely that the other number is higher than 2. But how do we quantify this increased likelihood, given that the other person can choose any strategy she likes?</p>
<p>Turns out we can let the math do the work for us. Let&#8217;s define the following strategy: <em>If we get 1, we say &#8216;higher&#8217;. If we get 2, we say &#8216;higher&#8217; with probability p. Otherwise we say &#8216;higher&#8217; with</em> <em>probability 0.5. </em>Our goal is to find the optimal &#8216;p&#8217;. Let&#8217;s say the other person first chooses 2, and then chooses a number greater than 2 with probability q, and a number lower than 2 (i.e. 1) with probablity 1-q. Our chances of winning in this case are:</p>
<p>P(win) = q*(0.5*0.5 + 0.5*p) + (1-q)*(0.5*(1-p) + 0.5*1)</p>
<p>Let&#8217;s explain this. There are actually three options: The other person can choose either greater than 2 or 1, we can get either 2 or the other number, and we can say &#8216;higher&#8217; or &#8216;lower&#8217;. So the first term, q*0.5*0.5, is the case where the other person chooses a number higher than 2 (prob. q), we get that number (prob. 0.5), and we say &#8216;lower&#8217; (prob. 0.5). Note that the last term is the one where the person chooses 1 and we get it, so we say &#8216;higher&#8217; and are correct with prob. 1. Now let&#8217;s simplify this:</p>
<p>P(win) = 0.5*[q*0.5 + q*p + (1-q)(2-p)] = 0.5*[2 - p + q*(0.5 - 2 + 2*p)] = 1 &#8211; 0.5*p + 0.5*q*(2*p &#8211; 3/2)</p>
<p>This last expression is quite cool. By choosing p=3/4, we can make the last term vanish and get P(win)=5/8  > 0.5 ! This is the crux of this method: We can choose a p that eliminates our dependence on q, which is the only control the other person has. So in effect this method allows us to take control of the problem, and to ensure our victory.</p>
<p>We can go on and solve the same problem in case we get 3, 4, and so on, finding the optimal probability for each. I won&#8217;t go into the calculation, but the resulting probabilities are: p(n) = 0.5*(0.5 + p(n-1)), i.e. the next probability is the average between 0.5 and the current probability, and p(1)=1 as before.<br />
As you can see, this forms a descending series of probabilities, and we already showed that such a series allows us to win the game. In a sense, this  is the optimal series of probabilities. And now you can see why this method works: It&#8217;s because the natural numbers have a minimal item, and we can use this leverage inductively to form a winning strategy.</p>
<p>Another related and interesting characteristic of this solution is that it is applicable to other number spaces, but only to those the have a minimum. For example, you can choose two real numbers in the interval [0,1]. In this case, we can use a descending function of probabilities p(x) to obtain the same result. But if the other person chooses two integer numbers (i.e. allowing both positive and negative), this method breaks down. Compare this with the first solution, which works for any number space.</p>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/23/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Two Envelopes</title>
		<link>http://4by12.com/blog/archives/15</link>
		<comments>http://4by12.com/blog/archives/15#comments</comments>
		<pubDate>Sat, 27 May 2006 03:04:59 +0000</pubDate>
		<dc:creator>Guy Gur Ari</dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://4by12.com/blog/archives/15</guid>
		<description><![CDATA[Players A and B play a game. Player A somehow selects two different natural numbers and puts them in two envelopes. He then chooses one envelope at random and hands it to player B. Player B looks at the number, and has to guess whether the number in the other envelope is higher or lower. [...]]]></description>
			<content:encoded><![CDATA[<p>Players A and B play a game. Player A somehow selects two different natural numbers and puts them in two envelopes. He then chooses one envelope at random and hands it to player B. Player B looks at the number, and has to guess whether the number in the other envelope is higher or lower.</p>
<p>The question is: How can player B guess correctly at probability > 0.5 on average?</p>
<p>There are some additional conditions: Player A knows the strategy player B uses to obtain the result, and he can use whatever counter-strategy he likes to select the two numbers. His only constraints are that the numbers must be different, and that the number that is revealed to player B is selected at random.</p>
<p><span id="more-15"></span></p>
<p>I know of two solutions to this riddle. I&#8217;ll present the first one here and leave the other to another post.</p>
<p>After player B receives the number, she selects a natural number using some distribution, making sure the new number is different from the number in the envelope, and making sure each natural number has a non-zero chance of being selected. Given the two numbers, this is what player B says:</p>
<ol>
<li>If the new number is larger than the envelope number, the answer is &#8216;higher&#8217;</li>
<li>Otherwise, the answer is &#8216;lower&#8217;</li>
</ol>
<p>Now, if both numbers in the envelopes are smaller than the number player B chooses, then player B is right with 0.5 probability (because the first envelope is selected at random). This is also true if both numbers are larger than the number player B chooses. But if the number she chooses is higher than one envelope number and smaller than the other, then player B is always correct.</p>
<p>Therefore, the chance of player B being correct is greater than 0.5 on average.</p>
<p>Note that the same solution would apply if we played with real or integer numbers instead of natural numbers.</p>
]]></content:encoded>
			<wfw:commentRss>http://4by12.com/blog/archives/15/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
