<?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>Yaniv&#039;s Gems &#187; Riddles</title>
	<atom:link href="http://yaniv.leviathanonline.com/blog/category/riddles/feed/" rel="self" type="application/rss+xml" />
	<link>http://yaniv.leviathanonline.com/blog</link>
	<description>Strain your Brain</description>
	<lastBuildDate>Mon, 28 Mar 2011 22:02:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Monochrome Lizards</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/monochrome-lizards/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/monochrome-lizards/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 22:02:25 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/?p=248</guid>
		<description><![CDATA[There are 3 types of lizards: yellow, green and blue. If you rub 2 lizards from different colors, they both change color to the third color. So, for example, if you rub a yellow lizard and a blue lizard, you get 2 green lizards. Say that you have X yellow lizards, Y green lizards and [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="Lizards" src="http://leviathanonline.com/wordpress/wp-content/uploads/2011/03/LizardMain-300x198.jpg" alt="Uniform Lizards" width="300" height="198" />There are 3 types of lizards: yellow, green and blue.</p>
<p>If you rub 2 lizards from different colors, they both change color to the third color. So, for example, if you rub a yellow lizard and a blue lizard, you get 2 green lizards.</p>
<p>Say that you have X yellow lizards, Y green lizards and Z blue lizards. <strong>For what values of X, Y and Z can you transform all the lizards to the same color?</strong></p>
<p>E.g. for X=3, Y=3 and Z=1 it is possible (rub the 3 yellow ones with the 3 green ones and get a total of 7 blue ones).</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/monochrome-lizards/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Zeroing an Array in Constant Time</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/zeroing-an-array-in-constant-time/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/zeroing-an-array-in-constant-time/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 10:04:41 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Comp]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/?p=202</guid>
		<description><![CDATA[This one is a really cool (and practical) riddle! Implement an &#8220;integer array&#8221; data structure, that supports the following 3 operations: Init(int n, int k) &#8211; initialize the array to be of size n and with all cells set to the value k. Get(int i) &#8211; return the value at cell i. Set(int i, int [...]]]></description>
			<content:encoded><![CDATA[<p>This one is a really cool (and practical) riddle!</p>
<p>Implement an &#8220;integer array&#8221; data structure, that supports the following 3 operations:</p>
<p><strong>Init(int <em>n</em>, int <em>k</em>)</strong> &#8211; initialize the array to be of size <em>n</em> and with all cells set to the value <em>k</em>.</p>
<p><strong>Get(int <em>i</em>)</strong> &#8211; return the value at cell <em>i</em>.</p>
<p><strong>Set(int <em>i</em>, int <em>k</em></strong><strong>)</strong> &#8211; set the value of cell <em>i</em> to <em>k</em>.</p>
<p>The catch &#8211; all 3 operations should take constant time (not amortized, not probabilistic).</p>
<p>Note &#8211; you can assume that malloc or new are constant time, but that the returned memory is filled with (adversarial) random.</p>
<p><span style="color: #0000ff;">Thanks to Nadav Sherman for this riddle!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/zeroing-an-array-in-constant-time/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Differing Neighbors</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/differing-neighbors/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/differing-neighbors/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 22:49:11 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Comp]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/?p=195</guid>
		<description><![CDATA[Algorithm A Given an array of N integers, sort the array, and find the 2 consecutive numbers in the sorted array with the maximum difference. Example &#8211; on input [1,7,3,2] output 4 (the sorted array is [1,2,3,7], and the maximum difference is 7-3=4). Algorithm A runs in O(NlogN) time. Implement an algorithm identical in function [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><strong>Algorithm A</strong></span></p>
<p>Given an array of N integers, sort the array, and find the 2 consecutive numbers in the sorted array with the maximum difference.<br />
<span style="text-decoration: underline;"><em>Example</em></span> &#8211; on input <strong>[1,7,3,2]</strong> output <strong>4</strong> (the sorted array is [1,2,3,7], and the maximum difference is 7-3=4).</p>
<p>Algorithm A runs in O(NlogN) time.</p>
<p>Implement an algorithm identical in function to algorithm A, that runs in O(N) time.</p>
<p><span style="color: #0000ff;">Thanks to Yossi Richter for this riddle!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/differing-neighbors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Prisoners with Bit Sequences</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/prisoners-with-bit-sequences/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/prisoners-with-bit-sequences/#comments</comments>
		<pubDate>Fri, 28 May 2010 15:45:55 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/?p=185</guid>
		<description><![CDATA[This is a hard riddle &#8211; it took me a couple of days (wall-time) to solve, but it was definitely worth it. Be warned &#8211; a certain mathematical maturity is needed&#8230; There are three prisoners and a guard. The guard has an infinite sequence that is either all 1&#8242;s (e.g. 1111111111&#8230;) or it starts with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/veryhard.gif"><img class="size-full wp-image-55 alignleft" title="veryhard.gif" src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/veryhard.gif" alt="" width="200" height="200" /></a></p>
<p><strong>This is a hard riddle &#8211; it took me a couple of days (wall-time) to solve, but it was definitely worth it. Be warned &#8211; a certain mathematical maturity is needed&#8230;</strong></p>
<p>There are three prisoners and a guard. The guard has an infinite sequence that is either all 1&#8242;s (e.g. 1111111111&#8230;) or it starts with a finite number of 1&#8242;s and eventually turns into 2&#8242;s (e.g. 1112222222&#8230;). The guard creates 3 bit sequences (i.e. composed entirely of 0&#8242;s and 1&#8242;s) such that the sum of the i&#8217;th bit in the 3 sequences is equal to the i&#8217;th element in his sequence (1 or 2).</p>
<p>He then gives each of the 3 prisoners one of the 3 bit sequences. Each prisoner sees only his own sequence and has to guess whether the guard&#8217;s sequence consists only of 1&#8242;s or whether it turns into 2&#8242;s eventually. Devise a method that will make sure the majority of the prisoners (i.e. at least 2) guess correctly.</p>
<p><span style="color: #0000ff;">Thanks Haran for giving me this cool riddle!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/prisoners-with-bit-sequences/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>The Better Half</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/the-better-half/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/the-better-half/#comments</comments>
		<pubDate>Wed, 19 May 2010 19:34:33 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Comp]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/?p=178</guid>
		<description><![CDATA[A cute and easy algorithmic riddle. You have an array of N bit strings each of length M. You know that there is at least one element that appears more than N/8 times in the array. Using O(M+log(N)) memory and O(NM) time, find such an element. An Easier Version Well, its actually almost exactly the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif"><img class="size-full wp-image-54 alignleft" title="easyriddle.gif" src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif" alt="" width="200" height="200" /></a>A cute and easy algorithmic riddle.</p>
<p>You have an array of N bit strings each of length M. You know that there is at least one element that appears more than N/8 times in the array. Using O(M+log(N)) memory and O(NM) time, find such an element.</p>
<p><span style="text-decoration: underline;"><strong>An Easier Version<br />
</strong></span></p>
<p>Well, its actually almost exactly the same, but solve the above riddle in case there is an element that appears more than N/2 times in the array. I managed to find 3 distinct solutions to this easier variation, but only one of which generalizes easily.</p>
<p><span style="color: #0000ff;">Thanks Nemo for giving me this riddle!</span></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/the-better-half/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Reverse &amp; Clean</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/reverse-clean/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/reverse-clean/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 20:48:04 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/reverse-clean/</guid>
		<description><![CDATA[The game of Reverse &#38; Clean is a one player game, played on an N by M board, filled with Reversi pieces. Each Reversi piece has a black side and a white side. The game starts with all pieces showing their white side, except for the piece in the lower right corner, which shows its [...]]]></description>
			<content:encoded><![CDATA[<p>The game of Reverse &amp; Clean is a one player game, played on an N by M board, filled with Reversi pieces. Each Reversi piece has a black side and a white side. The game starts with all pieces showing their white side, except for the piece in the lower right corner, which shows its black side. See the figure for a 3 by 3 example.</p>
<p><img title="reversi1.png" src="http://leviathanonline.com/wordpress/wp-content/uploads/2010/04/reversi1.png" alt="reversi1.png" /></p>
<p>In each turn of the game, you remove one of the black pieces and flip all of its (remaining) neighbours (the pieces up, down, left and right of it). The figures below demonstrate 2 possible first moves (note that the very first move of the game is always to remove the bottom right piece, which is the only black piece).</p>
<p><img title="reversi2.png" src="http://leviathanonline.com/wordpress/wp-content/uploads/2010/04/reversi2.png" alt="reversi2.png" /> <img src="http://leviathanonline.com/wordpress/wp-content/uploads/2010/04/reversi3.png" alt="reversi3.png" /></p>
<p>The goal of the game is to clean the board (i.e. remove all pieces). Note that if the board is 1 by N, you can always win, while if the board is 2 by 2, winning is impossible (make sure you see why).</p>
<p><em><strong>For what numbers, N and M, is a win possible?</strong></em></p>
<p>Extra Credit: What about 3-dimensions? D-dimensions?</p>
<p class="sidenote">Thanks to Liron Raz for giving me this one.</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/reverse-clean/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rabbit Season</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/rabbit-season/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/rabbit-season/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 09:30:56 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/rabbit-season/</guid>
		<description><![CDATA[There are 10 cells in a line. A transparent rabbit is in one of them. You have a shotgun, and obviously you want to shoot the rabbit. If you hit the cell with the rabbit, you kill him (and win). Otherwise, if you shoot an empty cell, the rabbit hears the shot, gets scared of [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif" title="easyriddle.gif" alt="easyriddle.gif" align="left" /><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2010/03/rabbit1.png" title="rabbit" alt="rabbit" align="right" />There are 10 cells in a line. A transparent rabbit is in one of them. You have a shotgun, and obviously you want to shoot the rabbit.</p>
<p>If you hit the cell with the rabbit, you kill him (and win). Otherwise, if you shoot an empty cell, the rabbit hears the shot, gets scared of the noise and jumps one cell to the right or one cell to the left. In case the rabbit is in the right-most cell, it can only jump to the left (and similarly, if the rabbit is in the left-most cell, it jumps to the right).</p>
<p>Can you kill the rabbit? If so, what is the minimum number of shots needed to guarantee a kill?</p>
<p><u><strong>Extra Credit</strong></u></p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/spoiler.gif" title="spoiler.gif" alt="spoiler.gif" align="left" /></p>
<p><em><strong>Spoiler Warning &#8211; read after solving the riddle above!</strong></em></p>
<p>Instead of considering the cells in a row, the riddle can be generalized to a graph.</p>
<p>If the graph has cycles, no solution exists (make sure you see why!).</p>
<p>What happens if the graph is a general tree?</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/rabbit-season/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Fat Aunts</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/fat-aunts/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/fat-aunts/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 22:16:40 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/fat-aunts/</guid>
		<description><![CDATA[Two aunts are living each in her own (0-dimensional) house. There are two non-intersecting (1-dimensional) roads between the houses. Last year, both aunts were doing a lot of exercise, and so they were slim (0-dimensional). They managed to walk together from House 1 to House 2, taking different roads, while each was holding one end [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2010/01/houses2.png" title="Houses" alt="Houses" align="left" />Two aunts are living each in her own (0-dimensional) house. There are two non-intersecting (1-dimensional) roads between the houses.</p>
<p>Last year, both aunts were doing a lot of exercise, and so they were slim (0-dimensional). They managed to walk together from House 1 to House 2, taking different roads, while each was holding one end of a rope of length less than L.</p>
<p>This year, they gained weight, and each became a sphere of radius L/2. One aunt is in House 1 and the other is in House 2. Can they exchange houses without bumping into each other (their centers must always remain on the roads)?</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/fat-aunts/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Really equal? Naturally!</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/really-equal-naturally/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/really-equal-naturally/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 11:27:15 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/really-equal-naturally/</guid>
		<description><![CDATA[You have a set of 2N+1 natural numbers, with the following property: if you remove any one element, you can partition the remaining 2N elements into two sets A and B, each of size N, such that the sum of the N numbers in set A equals the sum of the N numbers in set [...]]]></description>
			<content:encoded><![CDATA[<p>You have a set of 2N+1 natural numbers, with the following property: if you remove any one element, you can partition the remaining 2N elements into two sets A and B, each of size N, such that the sum of the N numbers in set A equals the sum of the N numbers in set B. Prove that all the numbers in the original set are equal.</p>
<p>Try to solve the riddle in the more general case, where the numbers are not necessarily natural, but arbitrary reals (some knowledge of algebra is helpful here).</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/really-equal-naturally/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Il Buono, il Brutto, il Cattivo</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/il-buono-il-brutto-il-cattivo/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/il-buono-il-brutto-il-cattivo/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 20:30:14 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/il-buono-il-brutto-il-cattivo/</guid>
		<description><![CDATA[For inspirational music, click here. Il Buono (nice and easy) Prove that in a subset of size n+1 of the set {1,2,&#8230;,2n} there are two numbers such that one divides the other. Il Cattivo (beautiful and hard) Prove that in a sequence of r*s+1 distinct numbers, there is either a monotonically increasing sub-sequence of length [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2009/07/goodbadugly.jpg" title="Good Bad Ugly" alt="Good Bad Ugly" align="left" /><em>For inspirational music, <a href="http://www.youtube.com/watch?v=4aniv65Mw8I&amp;feature=related" target="_blank">click here</a>. </em></p>
<p><u><strong>Il Buono</strong></u> (nice and easy)</p>
<p>Prove that in a subset of size n+1 of the set {1,2,&#8230;,2n} there are two numbers such that one divides the other.</p>
<p><u><strong>Il Cattivo</strong></u> (beautiful and hard)</p>
<p>Prove that in a sequence of r*s+1 distinct numbers, there is either a monotonically increasing sub-sequence of length r+1 or a monotonically decreasing sub-sequence of length s+1.</p>
<p><u><strong>Il Brutto</strong></u> (just easy)</p>
<p>Prove that in a subset of size n+1 of the set {1,2,&#8230;,2n} there are two relatively prime numbers (i.e. numbers whose gcd is 1).</p>
<p><u><strong>Il Non Collegato</strong></u> (another easy one)</p>
<p>Prove that a degree 7 polynomial with integer coefficients, that receives the values +1 or -1 on 7 integer points is irreducible over the integers.</p>
<p><em>Unusually, I decided to omit the second page, so post your solution related comments below.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/il-buono-il-brutto-il-cattivo/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Monty Hall Revised</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/monty-hall-revised/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/monty-hall-revised/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 10:31:44 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/monty-hall-revised/</guid>
		<description><![CDATA[This riddle is my take on the Monty Hall problem. If you know the original version, this one should be very easy for you. You are watching the TV series &#8220;Lets Make a Deal&#8221;. You are very excited as you know your friend Heidi is participating today. You watch attentively throughout the show, only to find [...]]]></description>
			<content:encoded><![CDATA[<p><em>This riddle is my take on the Monty Hall problem. If you know the original version, this one should be very easy for you.</em></p>
<p>You are watching the TV series &#8220;Lets Make a Deal&#8221;.</p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/07/lets_make_a_deal.gif" alt="lets_make_a_deal.gif" /></p>
<p>You are very excited as you know your friend Heidi is participating today. You watch attentively throughout the show, only to find out that it ends without Heidi ever appearing in it.</p>
<p>You call Heidi, several times during the following day, but you keep getting her answering machine. Maybe something happened to her?</p>
<p>You recall the <u><em>Rules of the Show</em></u>:</p>
<p>The host presents to each candidate three closed doors. Behind one of these doors hides a big prize, behind the other two there is an empty bucket. The candidate chooses one of the doors (this choice is random as he has no information whatsoever on the location of the prize). Then the host opens one of the other doors <em>behind which there is no prize</em>. Then the candidate is given the option to remain with his initial choice or to switch doors and choose the other closed door. Then the remaining doors are opened, and the candidate is awarded whatever is behind the door finally chose. The goal of the candidate is (obviously) to choose the door with the prize.</p>
<p>Pondering about the rules, you develop the following theory:</p>
<p>Maybe the host does not know in advance which of the doors contains the prize. In that case, if the host happens to choose to reveal the door with the prize (thus ruining the show) the candidate is killed (finally, some proper riddle scenario) and his scene is cut-out during the editing of the show.</p>
<p>Maybe that is what happened to Heidi?</p>
<p><strong>Assuming you have <em>a lot</em> of episodes (as many as you need), how can your theory be ruled out or strengthened?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/monty-hall-revised/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Hats in a Line</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/hats-in-a-line/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/hats-in-a-line/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 00:02:12 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/hats-in-a-line/</guid>
		<description><![CDATA[This riddle is a very cool extension of a well known (and easy) riddle, involving people with hats waiting in a line. So, lets begin with the original: The Original Riddle 100 men are standing in a line, such that each of them sees all those that are in-front of him (so the last man sees the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2008/05/hats_small2.jpg" alt="hats_small2.jpg" title="hats_small2.jpg" />This riddle is a very cool extension of a well known (and easy) riddle, involving people with hats waiting in a line.</p>
<p>So, lets begin with the original:</p>
<p><strong><u>The Original Riddle</u></strong></p>
<p>100 men are standing in a line, such that each of them sees all those that are in-front of him (so the last man sees the 99 others, etc.). Each guy has a hat on his head colored either black or white. Each of the men guesses the color of his own hat, out-loud. The guy standing last (the one that sees all the other ones) guesses first, then the guy in-front of him, etc. The men&#8217;s task is to make sure no more than one of them is wrong.</p>
<p>Just to make things explicit &#8211; the men are allowed to agree upon an algorithm before actually being given the hats, but once the task starts they cannot communicate in any way other than the fact that each of them hears the guess of the guys standing behind him.</p>
<p>Also, to conform to the universal standards of riddles, note that should more than one man be mistaken, they will all be brutally killed.</p>
<p>If you do not know this riddle yet, take a minute to think about its solution before reading on.</p>
<p><u><strong>The Solution of the Basic Riddle</strong></u></p>
<p>I give here the solution of the basic riddle so that there are no misunderstandings regarding the much more interesting extension. It goes like this &#8211; The last man (the one that guesses first) sacrifices himself (with a probability of 0.5). He regards each black hat as a 1 and each white hat as a 0. He then guesses out-loud that he has a black hat if the sum of all the hats of the other people is odd, and guesses white otherwise. The other people can all guess correctly (make sure that you understand why).</p>
<p><strong><u>Some Trivial Extensions</u></strong></p>
<p>Obviously the numbers 100 and 2 (the number of possible hat colors) in the original riddle are completely arbitrary. If m,n are two natural numbers then the riddle with m men and n possible hat colors is a trivial generalization of the previous result.</p>
<p>Now, note that if we let n, the number of possible hat colors, be equal to infinity (well, aleph 0, the cardinality of the set of natural numbers) then again we have a trivial generalization (make sure you see why).</p>
<p><strong><u>The Real Deal</u></strong></p>
<p>Now the extension of the riddle we are interested in consists of letting m, the number of people, be equal to aleph 0. For simplicity, lets assume that n equals two (the hats are either black or white).</p>
<p>Is the riddle still solvable? I.e. can the men devise an algorithm such that there will be only one mistake?</p>
<p>As usual, post solution related comments to the second page.</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/hats-in-a-line/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Valid Planar Pairing</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/valid-planar-pairing/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/valid-planar-pairing/#comments</comments>
		<pubDate>Sat, 24 Nov 2007 16:19:19 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/valid-planar-pairing/</guid>
		<description><![CDATA[There are 100 red dots and 100 blue dots on the plane (a lot of planar riddles lately). The dots are arranged such that no three are on the same line. A pairing of the red dots and the blue dots is a one-to-one function that assigns one blue dot to each red dot. A valid pairing is a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/11/pairing_icon.gif" alt="pairing_icon.gif" />There are 100 red dots and 100 blue dots on the plane (a lot of planar riddles lately). The dots are arranged such that no three are on the same line.</p>
<p>A <u><em>pairing</em></u> of the red dots and the blue dots is a one-to-one function that assigns one blue dot to each red dot.</p>
<p>A <u><em>valid pairing</em></u> is a pairing such that when paired dots are connected with a straight line segment, no line intersections occur. This is depicted here:</p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/11/pairing.gif" alt="pairing.gif" /></p>
<p>Prove that there exists a valid pairing.</p>
<p>I do not really like the solution I found for this riddle. If you find an elegant one, please post it.</p>
<p class="sidenote">Thanks to Nadav Sherman for giving me this one.</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/valid-planar-pairing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Uncountable Union</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/uncountable-union/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/uncountable-union/#comments</comments>
		<pubDate>Wed, 21 Nov 2007 15:09:42 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/uncountable-union/</guid>
		<description><![CDATA[A very interesting riddle for those of you with some basic background in Set Theory. Prove or Disprove the Following Claim: There exists a subset B of P(N), such that &#124;B&#124; = A, and B is completely ordered by the subset relation. Notes: N denotes the set of natural numbers. A denotes the cardinality of the [...]]]></description>
			<content:encoded><![CDATA[<p><img align="middle" src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif" alt="easyriddle.gif" title="easyriddle.gif" />A very interesting riddle for those of you with some basic background in Set Theory.</p>
<p><strong><u>Prove or Disprove the Following Claim:</u></strong></p>
<p>There exists a subset B of P(<em><strong>N</strong></em>), such that |B| = A, and B is completely ordered by the subset relation.</p>
<p><strong><u>Notes:</u></strong></p>
<p><em><strong>N</strong></em> denotes the set of natural numbers.</p>
<p>A denotes the cardinality of the continuum (i.e. A = aleph = 2^aleph 0).</p>
<p>&#8220;B is completely ordered by the subset relation&#8221; means that for every two elements a, b of B, either a is a subset of b or b is a subset of a.</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/uncountable-union/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Expanding Frogs</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/expanding-frogs/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/expanding-frogs/#comments</comments>
		<pubDate>Wed, 21 Nov 2007 14:52:12 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/expanding-frogs/</guid>
		<description><![CDATA[A very easy riddle. Four frogs are sitting on the corners of the unit square (i.e. they have coordinates (0,0), (0,1), (1,1) and (1,0) ). Each turn, a frog can jump over any other frog, thereby transferring itself to the symmetrical point on the other side of the static frog. For example, if the frog at [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/11/frog.thumbnail.jpg" alt="frog.jpg" />A very easy riddle. Four frogs are sitting on the corners of the unit square (i.e. they have coordinates (0,0), (0,1), (1,1) and (1,0) ). Each turn, a frog can jump over any other frog, thereby transferring itself to the symmetrical point on the other side of the static frog. For example, if the frog at (0,0) jumps over the frog at (1,1) it will land on (2,2).</p>
<p><img align="middle" src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif" alt="easyriddle.gif" title="easyriddle.gif" />Prove that the frogs cannot transfer themselves to a square with a side of length 2.</p>
<p>I know of two different solutions to this one (both easy <img src='http://leviathanonline.com/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ).</p>
<p class="sidenote">Thanks to Nadav Sherman for asking me this riddle.</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/expanding-frogs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Peons</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/peons/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/peons/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 17:08:45 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/peons/</guid>
		<description><![CDATA[ This is a cute puzzle. Consider an infinite checkerboard divided in two with an infinite line lying along the x-axis, as depicted below: You have several peons at your disposal. In each turn you can move the peons by making one of them jump over the other, thereby killing it (removing it from the board). The peon movement [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/10/peons_explain.thumbnail.jpg" alt="peons_explain.jpg" /> This is a cute puzzle. Consider an infinite checkerboard divided in two with an infinite line lying along the x-axis, as depicted below:</p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/10/peons_board.jpg" alt="peons_board.jpg" /></p>
<p>You have several peons at your disposal. In each turn you can move the peons by making one of them jump over the other, thereby killing it (removing it from the board). The peon movement is demonstrated here:</p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/10/peons_explain.jpg" alt="peons_explain.jpg" /></p>
<p>When the game starts, all the peons are below the line. Your goal is to place a peon above the line. The example shows how to accomplish this starting with two peons. Indeed it is obvious that in order to make a peon cross the line, two peons are needed (clearly one is not enough as it cannot move at all).</p>
<p>How many peons are needed in order to not only cross the line, but place a peon two squares above it? As is demonstrated below, four peons are sufficient, and indeed this is the minimum (check that you see why 2 and 3 peons cannot do it).</p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/10/peons_one_square.jpg" alt="peons_one_square.jpg" /></p>
<p>Now for the riddle. How many peons are needed (again, starting below the line) in order to place a peon 5 squares above the line?</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/peons/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Find the Duplicate</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/find-the-duplicate/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/find-the-duplicate/#comments</comments>
		<pubDate>Sat, 13 Oct 2007 19:54:35 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Comp]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/find-the-duplicate/</guid>
		<description><![CDATA[Dany Valevsky gave me this very cool riddle. You are given a vector of size N, the elements of which are numbers in the range 1,&#8230;,N-1. I.e. there is at least one repeating element. Give an algorithm that finds a repeating element (it does not matter which one, in case there are several) with O(N) time complexity [...]]]></description>
			<content:encoded><![CDATA[<p>Dany Valevsky gave me this very cool riddle.</p>
<p>You are given a vector of size N, the elements of which are numbers in the range 1,&#8230;,N-1. I.e. there is at least one repeating element. Give an algorithm that finds a repeating element (it does not matter which one, in case there are several) with O(N) time complexity and O(1) memory complexity.</p>
<p><strong><span style="text-decoration: underline;">NOTE </span></strong>- the time and memory complexities are calculated in integers. I.e. the input is of size N, not N*logN.</p>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/find-the-duplicate/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Pirates!</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/pirates/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/pirates/#comments</comments>
		<pubDate>Sat, 13 Oct 2007 19:45:42 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/pirates/</guid>
		<description><![CDATA[A ship in the plane has integer coordinates. It also has integer velocity (again in ZxZ). Each turn the ship advances according to its velocity. Here is an example of a ship with velocity (3, 1). You, as a pirate, want to blow up the ship. You do not know the original position of the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif" alt="easyriddle.gif" />A ship in the plane has integer coordinates. It also has integer velocity (again in ZxZ). Each turn the ship advances according to its velocity. Here is an example of a ship with velocity (3, 1).</p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/10/pirates.gif" alt="pirates.gif" /></p>
<p>You, as a pirate, want to blow up the ship. You do not know the original position of the ship nor its velocity. You can only shoot one bomb per turn, which blows up exactly one point of the plane. What strategy should you employ in order to be sure you will eventually hit the ship?</p>
<p>It is very recommended to watch to <a href="http://www.youtube.com/watch?v=1rtiAQk3ojE">this video</a> while solving the riddle. It provides great inspiration!</p>
<p class="sidenote">Thanks to Nadav Sherman for giving me this riddle.</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/pirates/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Piece of Cake</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/piece-of-cake/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/piece-of-cake/#comments</comments>
		<pubDate>Wed, 22 Aug 2007 23:58:50 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/piece-of-cake/</guid>
		<description><![CDATA[In this article you will find a collection of riddles. They are all either very well known or extremely easy. Enjoy! Cutting the Cake How can you cut a circular cake to eight even pieces with 3 cuts? What is the maximum number of pieces possible with 4 cuts? Colorblind Pills You have a rare and fatal disease. The only cure for [...]]]></description>
			<content:encoded><![CDATA[<p>In this article you will find a collection of riddles. They are all either very well known or extremely easy. Enjoy!</p>
<p><strong><u>Cutting the Cake</u></strong></p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/08/cake1.jpg" alt="cake1.jpg" />How can you cut a circular cake to eight even pieces with 3 cuts? What is the maximum number of pieces possible with 4 cuts?</p>
<p><strong><u>Colorblind Pills</u></strong></p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/08/red_or_blue_pill.jpg" alt="red_or_blue_pill.jpg" />You have a rare and fatal disease. The only cure for your disease is taking one <a href="http://www.rxlist.com/cgi/generic/clarith.htm">Biaxin</a> pill (which is blue) and one <a href="http://www.rxlist.com/cgi/generic/methocar.htm">Robaxin</a> pill (which is red) exactly at midnight, for two days. I.e. you have to take one of each today at midnight and one of each tomorrow at midnight, for a total of four pills. You have exactly four pills (two of each kind) at your disposal. The pills, apart from being in different colors, are identical in appearance.</p>
<p>Now, in addition to your fatal illness, you are also colorblind. How can you save yourself?</p>
<p>Note that in order to be saved you have to take the pills exactly as described above &#8211; e.g. taking all four pills at the same time will get you killed!</p>
<p>And no - there aren&#8217;t other people that can help you, etc&#8230;</p>
<p><strong><u>Cup of Coffee, Fuck of Tea </u></strong></p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/08/glass-of-milk.jpg" alt="glass-of-milk.jpg" />You have a cup of coffee and a cup of milk, both containing the same (unspecified) amount of liquid. You take one spoon full of milk and put it in the coffee. You mix well. You then return a spoon full of the mixture to the cup of milk. Which is more: milk in coffee or coffee in milk?</p>
<p>The title is taken from the famous Israeli movie <a href="http://www.imdb.com/title/tt0374053/">Operation Grandma</a>. Thanks to Misha Seltzer for this riddle.</p>
<p><strong><u>The Virgin Islands</u></strong></p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/08/british_virgin_islands_property.jpg" alt="british_virgin_islands_property.jpg" /> You are shipwrecked on the Virgin Islands (since <a href="http://4q.cc/index.php?pid=top100&amp;person=chuck">Chuck Norris</a> visited them, they are known simply as The Islands). You know that there are three tribes in the Islands: The <em>Liatu</em> tribe, that always lies, the <em>Honestu</em> tribe, that always tells the truth, and the <em>Randomu </em>tribe that answers randomly to every question asked. As you wander around the Islands, you come across 3 tribesmen. By the way they are dressed you can tell that they belong to different tribes (i.e. there is one member of each tribe) but you do not know to which tribe they belong. The native language on the Islands is French, which you speak fluently. It is well known that in French you can only ask &#8220;yes-no&#8221; questions. You are also familiar with an ancient tradition on the Islands, that says that it is impolite to ask more than 2 questions (each addressed to one specific person) per conversation, no más. You are standing at a fork and need to decide whether to go left or right. How can you get your information?</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/piece-of-cake/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>23 and 2000</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/23-and-2000/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/23-and-2000/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 12:51:31 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/23-and-2000/</guid>
		<description><![CDATA[You are given 23 whole numbers, not necessarily distinct, in a row. You cannot change the order of the numbers. Prove that there exists an arrangement of the symbols &#8217;+&#8217;, &#8216;×&#8217;, &#8216;(&#8216; and &#8216;)&#8217; in-between the 23 numbers, such that the final result is a valid formula, whose evaluated value equals 0 mod 2000. Extra Credit  Is 23 a tight [...]]]></description>
			<content:encoded><![CDATA[<p><img align="middle" src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif" alt="easyriddle.gif" title="easyriddle.gif" />You are given 23 whole numbers, not necessarily distinct, in a row.</p>
<p>You cannot change the order of the numbers.</p>
<p>Prove that there exists an arrangement of the symbols &#8217;<em>+&#8217;, &#8216;×&#8217;, &#8216;(&#8216; </em>and &#8216;<em>)&#8217; </em>in-between the 23 numbers, such that the final result is a valid formula, whose evaluated value equals 0 mod 2000.</p>
<p><strong><u>Extra Credit </u></strong></p>
<ol>
<li>Is 23 a tight bound? Can you find a sequence of 22 numbers such that all arrangements of the symbols &#8216;<em>+&#8217;, &#8216;×&#8217;, &#8216;(&#8216;</em> and<em> &#8216;)&#8217; </em>in-between them will result in numbers that are different from 0 mod 2000? I haven&#8217;t thought about this one yet, so please post your ideas!</li>
<li>Consider a more general case. Replace in the riddle above the number 23 by <em>K</em> and the number 2000 by <em>N.</em> Describe all the pairs, <em>K, N</em>, for which a solution to the riddle exists.</li>
</ol>
<p class="sidenote"><em>Thanks to Misha Seltzer, for sending me this cool riddle!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/23-and-2000/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>You are in my Seat!</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/you-are-in-my-seat/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/you-are-in-my-seat/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 17:50:30 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/you-are-in-my-seat/</guid>
		<description><![CDATA[ There are 100 seats in an airplane. There are 99 male passangers with reserved seats and one female passager that does not have a ticket. The female passanger enters the plane first, selects a random seat (out of the total 100 seats) and sits in it. Then the first man enters. If his seat is not [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/07/plane_seats.jpg" alt="plane_seats.jpg" /> There are 100 seats in an airplane.</p>
<p>There are 99 male passangers with reserved seats and one female passager that does not have a ticket.</p>
<p>The female passanger enters the plane first, selects a random seat (out of the total 100 seats) and sits in it.</p>
<p>Then the first man enters. If his seat is not taken he sits in it. If it is taken he selects a non-occupied random seat in the plane and sits there.</p>
<p>The rest of the men enters and does the same &#8211; each of them first tries to take his own seat (if it is available) and otherwise sits in a random non-occupied seat.</p>
<p><strong>What is the probability that the last man to enter the plane gets his original seat?</strong></p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif" alt="easyriddle.gif" /></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/you-are-in-my-seat/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Blindfolded Flipping</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/blindfolded-flipping/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/blindfolded-flipping/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 17:40:14 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/blindfold-flipping/</guid>
		<description><![CDATA[ There are 100 coins on the table. 90 of the coins have their Heads face up, the other 10 have their Tails face up. Your task is to split the coins into two groups, such that both groups contain the same number of coins with their Heads face up. You are even allowed to flip the coins&#8230; The catch is [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/07/blindfold_small.gif" alt="blindfold_small.gif" /> There are 100 coins on the table. 90 of the coins have their <em>Heads</em> face up, the other 10 have their <em>Tails</em> face up. Your task is to split the coins into two groups, such that both groups contain the same number of coins with their <em>Heads</em> face up. You are even allowed to flip the coins&#8230;</p>
<p><strong>The catch is that you cannot see the coins &#8211; you are blindfolded!</strong></p>
<p>What is your strategy?</p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif" alt="easyriddle.gif" /></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/blindfolded-flipping/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Spot The Not</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/spot-the-not/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/spot-the-not/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 17:18:52 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/spot-the-not/</guid>
		<description><![CDATA[This one is a riddle of my own invention. It gives a very good counter-example to something we tend to take for granted. Do not be discouraged &#8211; I posed it to one of my smartest professors and he did not find the answer! (at least not in the first five minutes&#8230;). The riddle requires some knowledge [...]]]></description>
			<content:encoded><![CDATA[<p>This one is a riddle of my own invention. It gives a very good counter-example to something we tend to take for granted. Do not be discouraged &#8211; I posed it to one of my smartest professors and he did not find the answer! (at least not in the first five minutes&#8230;).</p>
<p class="sidenote">The riddle requires some knowledge of <a href="http://en.wikipedia.org/wiki/Topology">Topology</a> and <a href="http://en.wikipedia.org/wiki/Real_analysis">Real-Analysis</a>.  For those of you lacking it, all the relevant definitions are included at the end (I recommend skimming through them before reading the riddle itself).</p>
<p><strong><u>This seemingly trivial list of claims leads to a contradiction. Can you find the error?</u></strong></p>
<ol>
<li>If A is an open subset of R, the R-A is a closed subset.</li>
<li>If A is a subset of R, then bdy(A) = bdy(R-A).</li>
<li>If T is the set of all irrational numbers in the segment [0,1], then u(A) = 1 (u is the Lebesgue measure).</li>
<li>There exists a closed set B contained in the set T (T as in 3) such that u(B) &gt; 0.9.</li>
<li>If A is an open subset of R, then A is a countable union of open intervals.</li>
<li>If I is an open interval then bdy(I) contains at most 2 points.</li>
<li>From 5 and 6 it follows that if A is an open subset of R, then bdy(A) is countable.</li>
<li>From 1, 2 and 7 it follows that if A is a closed subset of R then bdy(A) is countable.</li>
<li>From 8 it follows that if A is a closed set then u(A) = u(A-bdy(A)).</li>
<li>From 9 it follows that u(B-bdy(B)) &gt; 0.9 (where B is as in 4).</li>
<li>Let C=B-bdy(B). Then C is an open set contained in T with u(C) &gt; 0.9. This is clearly impossible since the only open set contained in T is the empty set with Lebesgue measure of 0!</li>
</ol>
<p>Can you &#8220;Spot the Not&#8221;?</p>
<p><strong><u>Definitions Used by the Riddle</u></strong></p>
<ol>
<li><em><u>Open set</u></em> &#8211; a set is called <u><em>open</em></u> if each point of the set is an <u><em>interior point</em></u> of the set.</li>
<li><u><em>Interior point</em></u> - a point p is called an <u><em>interior point</em></u> of a subset A of R if there exists e&gt;0 such that the interval (c-e,c+e) is contained in A.</li>
<li><em><u>Closed set</u></em> &#8211; a set is called <em><u>closed</u></em>if the limit of every converging sequence contained in the set is also in the set. It can  be shown that if A is an open set in R, then R-A is a closed set in R, and vise-versa. This is actually very easy - try to prove it!</li>
<li><em><u>Measure of an interval</u></em> &#8211; the <em><u>measure</u></em> of an interval I=(a,b) is denoted m(I) and is equal to b-a.</li>
<li><u><em>Lebesgue outer measure</em></u> &#8211; let A be a subset of R. The <u><em>Lebesgue outer measure</em></u> of A is defined as inf { Σm(Pi) | Pi are countably many open intervals and A is contained in union of the Pis }. Those of you unfamiliar with the definition of the <u><em>Lebesgue measure</em></u>, can replace the occurrences of <u><em>Lebesgue measure</em></u> with <u><em>Lebesgue outer measure</em></u> in the claims above.</li>
<li><u><em>Boundary</em></u> &#8211; the <u><em>boundary</em></u> of a subset A of R, denoted <u><em>bdy(A)</em></u> is the set { x | for all e&gt;0, (x-e,x+e) ∩ A, contains both a point from A and from R-A }.</li>
</ol>
<p>Good luck!</p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/07/lebesgue.gif" alt="lebesgue.gif" /></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/spot-the-not/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>What are the Odds?</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/what-are-the-odds/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/what-are-the-odds/#comments</comments>
		<pubDate>Fri, 20 Jul 2007 02:17:56 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/what-are-the-odds/</guid>
		<description><![CDATA[This is the first riddle I post in my site that I haven&#8217;t yet solved. Because of this, I give it the &#8220;very hard&#8221; icon. It may turn out to be easy &#8211; do not be intimidated! You are given a natural number N and two coins. You can set the probabilities of getting heads [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://leviathanonline.com/wordpress/wp-content/uploads/2007/07/coin.gif" title="coin.gif"><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/07/coin.gif" alt="coin.gif" /></a>This is the first riddle I post in my site that I haven&#8217;t yet solved.</p>
<p>Because of this, I give it the <em>&#8220;very hard&#8221;</em> icon. It may turn out to be easy &#8211; do not be intimidated!</p>
<p><a href="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/veryhard.gif" title="veryhard.gif"><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/veryhard.gif" alt="veryhard.gif" /></a></p>
<p>You are given a natural number N and two coins. You can set the probabilities of getting heads or tails on both coins as you wish. You are then asked to generate a random number uniformly distributed on the set { 1, 2, &#8230;, N }. The catch is that you must have a finite upper bound on the number of coin tosses you use.</p>
<p>Lets clarify the requirements of the riddle by a simple example. Say N=6. Setting the probabilities for the coins to 2/3 and 1/2 will do the trick, as we can generate a number uniformly distributed on the set { 1, 2, 3, 4, 5, 6 } with a maximum of 3 tosses of the two coins (can you see how?).</p>
<p>Good luck! </p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/what-are-the-odds/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Ants Revamped</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/ants-revamped/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/ants-revamped/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 22:24:55 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/ants-revamped/</guid>
		<description><![CDATA[Please make sure you have read (and solved) the original Ants riddle before reading on!   Here are two sequel questions to the original Ants riddle: Which is the last ant to fall off the stick? What is the maximum number of ant collisions possible? I want to thank Danny Valevsky for bringing these to my attention!]]></description>
			<content:encoded><![CDATA[<p><a href="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/ant-drawing2.jpg" title="ant-drawing2.jpg"><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/ant-drawing2.thumbnail.jpg" alt="ant-drawing2.jpg" /></a>Please make sure you have read (and solved) the original <a href="http://yaniv.leviathanonline.com/blog/riddles/ants/">Ants</a> riddle before reading on!</p>
<p> <a href="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/ant-drawing2.jpg" title="ant-drawing2.jpg"><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif" alt="easyriddle.gif" /></a></p>
<p>Here are two sequel questions to the original Ants riddle:</p>
<ol>
<li>Which is the last ant to fall off the stick?</li>
<li>What is the maximum number of ant collisions possible?</li>
</ol>
<p><em>I want to thank Danny Valevsky for bringing these to my attention!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/ants-revamped/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Divide and Conquer</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/divide-and-conquer/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/divide-and-conquer/#comments</comments>
		<pubDate>Fri, 08 Jun 2007 23:50:15 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/uncategorized/divide-and-conquer/</guid>
		<description><![CDATA[ Yesterday, Zohar Gilboa, with whom I take a PDE course, asked me the following riddle. I must admit it is probably the riddle I like the least on my site thus far. It is very easy though, and as Zohar told me he really liked it himself, I decided to publish it anyways. Consider the following image: Your goals are: Divide [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/divide_and_conquer.thumbnail.gif" alt="divide_and_conquer.gif" /> Yesterday, Zohar Gilboa, with whom I take a PDE course, asked me the following riddle. I must admit it is probably the riddle I like the least on my site thus far. It is very easy though, and as Zohar told me he really liked it himself, I decided to publish it anyways.</p>
<p>Consider the following image:</p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/divide_and_conquer.gif" alt="divide_and_conquer.gif" /></p>
<p>Your goals are:</p>
<ol>
<li>Divide shape 1 (bluish) to two equal parts.</li>
<li>Divide shape 2 (greenish) to three equal parts.</li>
<li>Divide shape 3 (yellowish) to four equal parts.</li>
<li>Divide shape 4 (purplish) to five equal parts.</li>
</ol>
<p>All the division parts mentioned should be continuous shapes.</p>
<p style="background-color: #ffeeee">The second page contains the solution! Please only visit it after giving the riddle some thought&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/divide-and-conquer/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Two Envelopes</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/two-envelopes/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/two-envelopes/#comments</comments>
		<pubDate>Sat, 02 Jun 2007 00:52:35 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/two-envelopes/</guid>
		<description><![CDATA[You write down 2 numbers on 2 pieces of paper (one number on each piece). You put each paper in a sealed envelope. I choose one of the envelopes randomly and open it. I then carry out a certain procedure at the end of which I know with a probability greater than 1/2 whether I received the larger or the smaller of the numbers. I can do this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/envelopes_small.gif" title="Envelopes"><img align="left" src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/envelopes_small.gif" alt="Envelopes" title="Envelopes" /></a>You write down 2 numbers on 2 pieces of paper (one number on each piece). You put each paper in a sealed envelope. I choose one of the envelopes randomly and open it. I then carry out a certain procedure at the end of which I know with a probability <strong>greater </strong>than 1/2 whether I received the larger or the smaller of the numbers. I can do this even if when you initially wrote down the numbers, you knew my decision procedure!</p>
<p>How can I do that? What is my trick?</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/two-envelopes/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Guess my Number</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/guess-my-number/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/guess-my-number/#comments</comments>
		<pubDate>Fri, 25 May 2007 23:53:12 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/guess-my-number/</guid>
		<description><![CDATA[Well, it is time for a cool and easy riddle. 100 men are each assigned a number between 1-100 with repetitions (e.g. all of them may be assigned the number 17). Each of the men sees all the numbers assigned to all the other 99 men, but none of them sees the number assigned to [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/easyriddle.gif" alt="easyriddle.gif" title="easyriddle.gif" />Well, it is time for a cool and easy riddle. 100 men are each assigned a number between 1-100 with repetitions (e.g. all of them may be assigned the number 17). Each of the men sees all the numbers assigned to all the other 99 men, but none of them sees the number assigned to himself.</p>
<p>Each of them needs to guess his own number (of course no information is exchanged between them &#8211; no one hears what others have guessed etc.). What strategy can they employ in order to make sure at least one of them makes a correct guess?</p>
<p>Some followup thoughts:</p>
<ul>
<li>Can they make sure more than one person succeeds?</li>
<li>How many different solutions to the riddle are there (i.e. how many strategies can the men employ?).</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/guess-my-number/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Whole Rectangles</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/whole-rectangles/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/whole-rectangles/#comments</comments>
		<pubDate>Fri, 25 May 2007 18:16:08 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/whole-rectangles/</guid>
		<description><![CDATA[A short introduction to Graph Theory is needed for this one. If you already are familiar with Graph Theoretic constructs feel free to skip it. A graph G, is a pair (V,E) where V is a set of vertices and E is a set of edges. Each edge is an unordered pair of the form (u, [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/veryhard.gif" alt="veryhard.gif" title="veryhard.gif" />A short introduction to Graph Theory is needed for this one. If you already are familiar with Graph Theoretic constructs feel free to skip it.</p>
<p>A <em><u>graph</u></em> <em>G</em>, is a pair <em>(V,E)</em> where <em>V</em> is a set of <em><u>vertices</u></em> and <em>E</em> is a set of <em><u>edges</u></em>. Each edge is an unordered pair of the form <em>(u, v)</em> where <em>u</em> and <em>v </em>are vertices (i.e. they belong to <em>V</em>). The <em><u>degree</u></em> of a vertex <em>t</em> (denoted <em><u>deg(t)</u></em>) is the number of edges containing it:</p>
<p><em>deg(t) = #{ e | e = (s, t) ^ s belongs to V }</em></p>
<p>In this post I only consider <em><u>finite</u></em> and <em><u>simple graphs</u></em>. A <em><u>finite graph</u></em> is a graph whose vertex-set <em>V</em> is a finite set. A <em><u>simple graph</u></em> is a graph in which there are no <u><em>loops</em></u> (i.e. edges of the form <em>(u, u)</em>) and no <em><u>multiple edges</u></em> (i.e. <em>E</em> is a proper set so it cannot contain the same element twice).</p>
<p>The following is a trivial claim:</p>
<p><em>The sum of the degrees in a graph equals twice the number of edges.</em></p>
<p>It is trivial to prove this claim by induction on the number of edges (on a graph with no edges it is clear, and by adding an edge to the edge set of the graph the sum of degrees increases by two).</p>
<p>Use this claim to solve the following riddle:</p>
<p>A rectangle is called <em><u>whole</u> </em>if at least one of its sides is an integer. For example, a rectangle of 2 by 3/5 is whole as well as a rectangle of sqrt(5) by 3. A rectangle of 1/2 by 1/2 is not whole. Examples:</p>
<p><img width="800" src="http://yaniv.leviathanonline.com/blog/images/rectangles.gif" alt="Rectangle Exmaple" height="400" style="width: 800px; height: 400px" title="Rectangle Exmaple" /></p>
<p>A set <em>T</em> of rectangles constitues a <em><u>tiling</u></em> of a rectangle <em>R</em> if the rectangles in <em>T</em> are disjoint and for every point <em>p</em> in <em>R</em> there is a rectangle <em>S</em> in <em>T</em> such that <em>p</em> belongs to <em>S</em>. Example:</p>
<p><img width="400" src="http://yaniv.leviathanonline.com/blog/images/tiling.gif" alt="Tiling Example" height="200" style="width: 400px; height: 200px" title="Tiling Example" /></p>
<p>Prove that if <em>R</em> is a rectangle and <em>T</em> is a tiling of <em>R</em> consisting only of whole rectangles (i.e. every rectangle <em>S</em> in <em>T</em> is whole) then <em>R</em> is whole.</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/whole-rectangles/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Smart Disagreement</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/smart-disagreement/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/smart-disagreement/#comments</comments>
		<pubDate>Wed, 23 May 2007 15:15:53 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/smart-disagreement/</guid>
		<description><![CDATA[This one is a riddle of my own invention. I am really proud of it as it sounds impossible at first, but it can be resolved in a very satisfying fashion. I must admit that had I heard about it from someone else I would not have gone through the trouble of trying to solve it, as [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://yaniv.leviathanonline.com/blog/images/dice.gif" alt="Dice" title="Dice" />This one is a riddle of my own invention. I am really proud of it as it sounds impossible at first, but it can be resolved in a very satisfying fashion. I must admit that had I heard about it from someone else I would not have gone through the trouble of trying to solve it, as it sounds like a &#8221;cheap-trick&#8221; riddle. I can only ask you to trust me that it is indeed a purely mathematical riddle. Although it did provoke several harsh disputes with some very smart people (Matan, Eyal, how are you guys?), I was able to finally convince them of the mathematical validity of my solution.</p>
<p>The riddle goes like this:</p>
<p>A group of very smart men perform an experiment. There are no restrictions on the men&#8217;s behaviour during the experiment. After the experiment is over, each of the men reveals to all the others everything that he knows. Despite the fact that none of the men lies and they all know of everything that happened, there are 2 individuals in the group that reach different scientific conclusions. Your task is to devise such an experiment.</p>
<p>Note that the experiment is scientific in that it does not concern individual tastes or opinions. All the men are assumed to come from similar backgrounds and have similar likings. The different conclusions regard real aspects of nature.</p>
<p class="sidenote">The dice picture is a (vague) reference to one variant of my solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/smart-disagreement/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Perl vs. Python One-Liner</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/perl-vs-python-one-liner/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/perl-vs-python-one-liner/#comments</comments>
		<pubDate>Sat, 19 May 2007 22:45:11 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Comp]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/perl-vs-python-one-liner/</guid>
		<description><![CDATA[A few years ago a friend of mine asked me the following Perl riddle. Unfortunately, in order to solve it you must know Perl. As I like Python much better, I translated the riddle to Python. Attached are both versions. I admit the Perl version is a bit more cryptic and if you know both Perl and Python you [...]]]></description>
			<content:encoded><![CDATA[<p>A few years ago a friend of mine asked me the following Perl riddle. Unfortunately, in order to solve it you must know Perl. As I like Python much better, I translated the riddle to Python. Attached are both versions.</p>
<p>I admit the Perl version is a bit more cryptic and if you know both Perl and Python you should try to solve the Perl version (but use Python for everything else in life <img src='http://leviathanonline.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ).</p>
<p>Oh, and try to solve the riddle without running it (run it only as a last resort).</p>
<p><img align="middle" width="145" src="http://yaniv.leviathanonline.com/blog/images/perl_logo2.gif" alt="Perl Logo" height="75" style="width: 145px; height: 75px" title="Perl Logo" /></p>
<p><code>perl -wle 'print "True" if (1 x shift) !~ /^1?$|^(11+?)\1+$/' [number]</code></p>
<p><img align="middle" width="149" src="http://yaniv.leviathanonline.com/blog/images/python-logo.png" alt="Python Logo" height="148" style="width: 149px; height: 148px" title="Python Logo" /></p>
<p><code>python -c "import sys, re; print None == re.match('^1?$|^(11+?)\\1+$','1'*int(sys.argv[1]))" [number]</code></p>
<p>To alleviate all doubt &#8211; [number] denotes a numeric command line argument (e.g. 17).</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/perl-vs-python-one-liner/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Find Your Name</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/find-your-name/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/find-your-name/#comments</comments>
		<pubDate>Sun, 13 May 2007 05:19:26 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://yaniv.leviathanonline.com/blog/riddles/find-your-name/</guid>
		<description><![CDATA[I had a lot of thinking before deciding to include this riddle in my site. The argument for not including it, is that it is too complicated. I ended up deciding it deserves its place in my riddles section (which means I believe it is one of the most beautiful riddles ever) because, well, I think it [...]]]></description>
			<content:encoded><![CDATA[<p>I had a lot of thinking before deciding to include this riddle in my site. The argument for not including it, is that it is too complicated. I ended up deciding it deserves its place in my riddles section (which means I believe it is one of the most beautiful riddles ever) because, well, I think it is one of the most beautiful riddles ever. So enjoy! (but be ready for a hard one&#8230;):</p>
<p><img src="http://leviathanonline.com/wordpress/wp-content/uploads/2007/06/veryhard.gif" alt="veryhard.gif" /></p>
<p>There are 100 men, 100 boxes and 100 notes with the men&#8217;s names on them. The 100 boxes are arranged in a line in a room. Each of the notes with the names is put in a different box randomly. The men are put together and are allowed to decide upon a strategy. When they are done, they are taken, each in his turn, to the room with the boxes. Each one is allowed to open 50 of the boxes. <strong><u>No information whatsoever is shared between the men</u></strong>.</p>
<p>The goal of the men is that each of them finds his own name among the 50 boxes he opened. If but one of them fails to find his own name, they all get killed (why is it, that in so many riddles people end up dead?). You are required to find a method with which they are all saved with a probability of above 30%.</p>
<p>If you understood this riddle properly, it should seem impossible to you at first.</p>
<p>Because the riddle contains many details and to make sure I explained it properly, lets consider two bad strategies for the men:</p>
<p>1. All the men decide to open the same 50 boxes &#8211; this is probably the worst strategy for them, as all of them will die with probability 1. This is because 50 of them are sure not to find their names in the boxes they open.</p>
<p>2. Every man open 50 boxes randomly &#8211; although a better strategy than the former one, it is a very bad strategy. Each person is likely to find his own name with a probability of 1/2. As all the events of the men finding their names are independent, they will be saved with a probability of (1/2)^100.</p>
<p>As this number is smaller than 0.00000000000000000000000000000079 (which is obviously smaller than 30%) it is a very bad strategy indeed.</p>
<p>BTW - to calculate the above number I used the following python statement:<br />
<code>&gt;&gt;&gt; '%1.32f'%0.5**100</code></p>
<p style="background-color: #ffeeee">Solution now available on next page!</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/find-your-name/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Ants</title>
		<link>http://yaniv.leviathanonline.com/blog/riddles/ants/</link>
		<comments>http://yaniv.leviathanonline.com/blog/riddles/ants/#comments</comments>
		<pubDate>Fri, 11 May 2007 13:54:07 +0000</pubDate>
		<dc:creator>yaniv</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Riddles]]></category>

		<guid isPermaLink="false">http://leviathanonline.com/wordpress/?p=3</guid>
		<description><![CDATA[This is probably the best riddle I know of. There are 1000 ants walking on a horizontal stick, 1m long. Each ant is walking at a constant rate of 1m/hour. The ants start out in random locations on the stick, some walking to the left and some to the right. Whenever two ants meet they [...]]]></description>
			<content:encoded><![CDATA[<p>This is probably the best riddle I know of.</p>
<p>There are 1000 ants walking on a horizontal stick, 1m long.</p>
<p>Each ant is walking at a constant rate of 1m/hour.</p>
<p>The ants start out in random locations on the stick, some walking to the left and some to the right.</p>
<p>Whenever two ants meet they reverse their direction, as follows:</p>
<p><img width="690" src="http://yaniv.leviathanonline.com/blog/images/ants.gif" alt="Riddle Illustration" height="600" style="width: 690px; height: 600px" title="Riddle Illustration" /></p>
<p>Whenever an ant reaches one of the ends of the stick, it falls off (eventually all ants will fall).</p>
<p>What is the longest time it will take the last ant to fall off the stick?</p>
<p style="background: #ffeeee">The Ants riddle is one of the best riddles ever. It requires an imaginative mind, but does not require any knowledge of mathematics. A talented 6 year old can solve it!That is not to say it is very easy, but you can solve it yourself. DO NOT DESPAIR!</p>
<p>If you already solved the riddle and want to see the solution &#8211; visit the second page below.</p>
]]></content:encoded>
			<wfw:commentRss>http://yaniv.leviathanonline.com/blog/riddles/ants/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

