<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>Comments for Ashutosh Mehra's Blog</title>
	
	<link>http://ashutoshmehra.net/blog</link>
	<description>Notes on Math, Computer Science &amp; Programming</description>
	<lastBuildDate>Sat, 27 Feb 2010 14:23:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CommentsForAshutoshMehraBlog" /><feedburner:info uri="commentsforashutoshmehrablog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Comment on The Wire Identification Problem by Ashutosh</title>
		<link>http://feedproxy.google.com/~r/CommentsForAshutoshMehraBlog/~3/yrPcM8dmDKo/</link>
		<dc:creator>Ashutosh</dc:creator>
		<pubDate>Sat, 27 Feb 2010 14:23:21 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=598#comment-1527</guid>
		<description>@v: Never tried ;-)</description>
		<content:encoded><![CDATA[<p>@v: Never tried ;-)</p>
<img src="http://feeds.feedburner.com/~r/CommentsForAshutoshMehraBlog/~4/yrPcM8dmDKo" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://ashutoshmehra.net/blog/2009/09/wire-identification-problem/comment-page-1/#comment-1527</feedburner:origLink></item>
	<item>
		<title>Comment on The Wire Identification Problem by v</title>
		<link>http://feedproxy.google.com/~r/CommentsForAshutoshMehraBlog/~3/EkCa2-RSyvw/</link>
		<dc:creator>v</dc:creator>
		<pubDate>Mon, 25 Jan 2010 06:40:39 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=598#comment-1526</guid>
		<description>hi,
you have got great credentials.. ever tried to work for google ?</description>
		<content:encoded><![CDATA[<p>hi,<br />
you have got great credentials.. ever tried to work for google ?</p>
<img src="http://feeds.feedburner.com/~r/CommentsForAshutoshMehraBlog/~4/EkCa2-RSyvw" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://ashutoshmehra.net/blog/2009/09/wire-identification-problem/comment-page-1/#comment-1526</feedburner:origLink></item>
	<item>
		<title>Comment on The Wire Identification Problem by Ashutosh</title>
		<link>http://feedproxy.google.com/~r/CommentsForAshutoshMehraBlog/~3/E15y86Q5D14/</link>
		<dc:creator>Ashutosh</dc:creator>
		<pubDate>Fri, 08 Jan 2010 22:45:33 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=598#comment-1525</guid>
		<description>Ceiling[Log[2,n]]-step method is for your modified problem description (where each optical fiber can be ON/OFF). For eight wires labeled {000,001,...,111} in binary, you'll need 3 steps:
1. Turn on the just wires 1,3,5,7 on end A. On end B, label the wires -- the ON and OFF groups will be {xx0, xx1}, each with 4 wires.
2. Next turn on just the wires 2,3,6,7. On end B, the two group classifications will be re-classified as {x00, x01, x10, x11}.
3. Next turn on just 4,5,6,7. End B will now have 8 "groups": {000, 001, ..., 111}.

And yes, n/2 splitting (for this modified problem) _should_ be optimal as it transmits maximum information. And I think the _proof_ should be obvious from some information theoretic point-of-view.

So, I think this modified optic-fiber problem turns out to be easy after all; compared to the original copper-wire problem that involved more interesting math. And that deeper problem always (when n != 2,5,9) has a 2-step solution compared to the best Log[2,n]-step solution of the simpler problem!</description>
		<content:encoded><![CDATA[<p>Ceiling[Log[2,n]]-step method is for your modified problem description (where each optical fiber can be ON/OFF). For eight wires labeled {000,001,&#8230;,111} in binary, you&#8217;ll need 3 steps:<br />
1. Turn on the just wires 1,3,5,7 on end A. On end B, label the wires &#8212; the ON and OFF groups will be {xx0, xx1}, each with 4 wires.<br />
2. Next turn on just the wires 2,3,6,7. On end B, the two group classifications will be re-classified as {x00, x01, x10, x11}.<br />
3. Next turn on just 4,5,6,7. End B will now have 8 &#8220;groups&#8221;: {000, 001, &#8230;, 111}.</p>
<p>And yes, n/2 splitting (for this modified problem) _should_ be optimal as it transmits maximum information. And I think the _proof_ should be obvious from some information theoretic point-of-view.</p>
<p>So, I think this modified optic-fiber problem turns out to be easy after all; compared to the original copper-wire problem that involved more interesting math. And that deeper problem always (when n != 2,5,9) has a 2-step solution compared to the best Log[2,n]-step solution of the simpler problem!</p>
<img src="http://feeds.feedburner.com/~r/CommentsForAshutoshMehraBlog/~4/E15y86Q5D14" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://ashutoshmehra.net/blog/2009/09/wire-identification-problem/comment-page-1/#comment-1525</feedburner:origLink></item>
	<item>
		<title>Comment on The Wire Identification Problem by Nick</title>
		<link>http://feedproxy.google.com/~r/CommentsForAshutoshMehraBlog/~3/PEa_RVqJwUk/</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Fri, 08 Jan 2010 21:41:40 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=598#comment-1524</guid>
		<description>Ashutosh -

I think your Ceiling[Log[2,n]]-step assertion is correct, but I'm confused about your method. For eight wires are you saying you should light in the following pattern?
00000001
00000010
00000011
00000100
00000101
00000110
00000111
00001000

Most of those are redundant and you still wouldn't know four of them. I'm either misunderstanding you and/or you meant something like this:
11110000
11001100
10101010

This is such a simple method, I wonder if there isn't some more complexity lying within this problem once n gets bigger...

I'm starting to be convinced that there is not. Any initial n-splitting with k "on" wires, no matter how complex, is essentially "isomorphic" to an (n-k)k split, that is, 11001100 ~= 11110000 ~= 10101010. Then it essentially becomes two problems - (n-k) and k. Just judging from our small samples clearly it is better when k = n/2, or as close as possible if n is odd. If k = n/2 is the ideal split, then Ceiling[Log[2,n]] should be correct, no?

For example if instead of splitting 8 into 4-4 we split into 6-2 we'd end up taking four steps instead of three, since we have the initial split and 6 takes three steps.

hmm...</description>
		<content:encoded><![CDATA[<p>Ashutosh -</p>
<p>I think your Ceiling[Log[2,n]]-step assertion is correct, but I&#8217;m confused about your method. For eight wires are you saying you should light in the following pattern?<br />
00000001<br />
00000010<br />
00000011<br />
00000100<br />
00000101<br />
00000110<br />
00000111<br />
00001000</p>
<p>Most of those are redundant and you still wouldn&#8217;t know four of them. I&#8217;m either misunderstanding you and/or you meant something like this:<br />
11110000<br />
11001100<br />
10101010</p>
<p>This is such a simple method, I wonder if there isn&#8217;t some more complexity lying within this problem once n gets bigger&#8230;</p>
<p>I&#8217;m starting to be convinced that there is not. Any initial n-splitting with k &#8220;on&#8221; wires, no matter how complex, is essentially &#8220;isomorphic&#8221; to an (n-k)k split, that is, 11001100 ~= 11110000 ~= 10101010. Then it essentially becomes two problems &#8211; (n-k) and k. Just judging from our small samples clearly it is better when k = n/2, or as close as possible if n is odd. If k = n/2 is the ideal split, then Ceiling[Log[2,n]] should be correct, no?</p>
<p>For example if instead of splitting 8 into 4-4 we split into 6-2 we&#8217;d end up taking four steps instead of three, since we have the initial split and 6 takes three steps.</p>
<p>hmm&#8230;</p>
<img src="http://feeds.feedburner.com/~r/CommentsForAshutoshMehraBlog/~4/PEa_RVqJwUk" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://ashutoshmehra.net/blog/2009/09/wire-identification-problem/comment-page-1/#comment-1524</feedburner:origLink></item>
	<item>
		<title>Comment on The Wire Identification Problem by Ashutosh</title>
		<link>http://feedproxy.google.com/~r/CommentsForAshutoshMehraBlog/~3/tKtrQJUYNJM/</link>
		<dc:creator>Ashutosh</dc:creator>
		<pubDate>Fri, 08 Jan 2010 20:14:52 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=598#comment-1523</guid>
		<description>That's an interesting problem, Nick!

For 5 wires, by working out all possible two-step solutions, it looks clear to me that a three-step solution is the best possible.

In general, a Ceiling[Log[2,n]]-step solution is easy: Number the wires {0,1,...,n-1}. In the kth step, turn on the lights of wires the binary representation of which have kth bit ON. On the other end, keep building the IDs of each wire, a bit at each step.

Now the question is: Could some clever scheme do better than Ceiling[Log[2,n]]-steps?</description>
		<content:encoded><![CDATA[<p>That&#8217;s an interesting problem, Nick!</p>
<p>For 5 wires, by working out all possible two-step solutions, it looks clear to me that a three-step solution is the best possible.</p>
<p>In general, a Ceiling[Log[2,n]]-step solution is easy: Number the wires {0,1,&#8230;,n-1}. In the kth step, turn on the lights of wires the binary representation of which have kth bit ON. On the other end, keep building the IDs of each wire, a bit at each step.</p>
<p>Now the question is: Could some clever scheme do better than Ceiling[Log[2,n]]-steps?</p>
<img src="http://feeds.feedburner.com/~r/CommentsForAshutoshMehraBlog/~4/tKtrQJUYNJM" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://ashutoshmehra.net/blog/2009/09/wire-identification-problem/comment-page-1/#comment-1523</feedburner:origLink></item>
	<item>
		<title>Comment on The Wire Identification Problem by Nick</title>
		<link>http://feedproxy.google.com/~r/CommentsForAshutoshMehraBlog/~3/CkdX1ZTD_PM/</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Fri, 08 Jan 2010 19:46:18 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=598#comment-1522</guid>
		<description>Another interesting related, but different (I think) problem arises if you let the wires be optical fibers capable of representing two states (on and off or whathaveyou).

The two-wire situation is now obvious. Besides that I've only looked at the five wore situation which can be solved in three steps as follows:

For wires A,B,C,D, and E, light up A, B, and C and mark that group somehow. Then light up A, and D. This will give you A (lit up both times), D (lit up once), and E (never lit up). Now you have the two wire situation (B and C) and so one more step will do it.

Not sure if it can be done in two steps, nor do I have an inkling towards the general solution.

Is anyone aware if this is a solved problem? Please don't tell me Erdös solved it :).</description>
		<content:encoded><![CDATA[<p>Another interesting related, but different (I think) problem arises if you let the wires be optical fibers capable of representing two states (on and off or whathaveyou).</p>
<p>The two-wire situation is now obvious. Besides that I&#8217;ve only looked at the five wore situation which can be solved in three steps as follows:</p>
<p>For wires A,B,C,D, and E, light up A, B, and C and mark that group somehow. Then light up A, and D. This will give you A (lit up both times), D (lit up once), and E (never lit up). Now you have the two wire situation (B and C) and so one more step will do it.</p>
<p>Not sure if it can be done in two steps, nor do I have an inkling towards the general solution.</p>
<p>Is anyone aware if this is a solved problem? Please don&#8217;t tell me Erdös solved it :).</p>
<img src="http://feeds.feedburner.com/~r/CommentsForAshutoshMehraBlog/~4/CkdX1ZTD_PM" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://ashutoshmehra.net/blog/2009/09/wire-identification-problem/comment-page-1/#comment-1522</feedburner:origLink></item>
	<item>
		<title>Comment on Aha! Emacs 23! by Anonymous coward</title>
		<link>http://feedproxy.google.com/~r/CommentsForAshutoshMehraBlog/~3/ekZFDN6M6bc/</link>
		<dc:creator>Anonymous coward</dc:creator>
		<pubDate>Fri, 04 Sep 2009 03:17:39 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=327#comment-1508</guid>
		<description>Thank you for taking the time to write such a thoughtful and entertaining review.</description>
		<content:encoded><![CDATA[<p>Thank you for taking the time to write such a thoughtful and entertaining review.</p>
<img src="http://feeds.feedburner.com/~r/CommentsForAshutoshMehraBlog/~4/ekZFDN6M6bc" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://ashutoshmehra.net/blog/2009/04/aha-emacs-23/comment-page-1/#comment-1508</feedburner:origLink></item>
	<item>
		<title>Comment on Kernighan &amp; Plauger on Programming Style by Ashutosh</title>
		<link>http://feedproxy.google.com/~r/CommentsForAshutoshMehraBlog/~3/IwvsjROKmRU/</link>
		<dc:creator>Ashutosh</dc:creator>
		<pubDate>Mon, 13 Jul 2009 18:07:52 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=556#comment-993</guid>
		<description>Thanks for the comment, Sam.

While the book doesn't ever mention "functional programming", many of K&amp;P's suggestions, as you said, work nicely with FP:

Functions in FP tend to be naturally small: It is interesting to ponder what makes programming with FP-flavor lead naturally to smaller, shorter, more concise functions. It could well be that this is my personal feeling because I've never really programmed "real-world" programs to solve "real" problems. But I suspect it is more generally true: Functions in imperative languages tend to be longer.

Functions in FP are more loosely coupled. Again, this is arguable. But I think using lists or property-bags as common data-structures leads to looser coupling.

And of course, FP eliminates a whole variety of errors related to order of assignment, uninitialized variables, using evil control structures... &lt;i&gt;FP is good&lt;/i&gt;.

As for top-down design, "successive refinement" does seem to be a good way to &lt;i&gt;understand&lt;/i&gt; a solution, if not necessarily &lt;i&gt;design&lt;/i&gt; one -- it helps understand the interactions between the players before delving in details on how each one does its job.

Perhaps top-down vs. bottom-up is like this: Which do you do first when coding or defining a recursive function -- code the "recursion part" first, or, code the base case first? Most times, I think, it is more natural do the "recursion part" first, if only because it helps clarify what the base cases should be -- precisely the cases for which it makes no further sense to subdivide the problem to conquer it!

But Top-down vs. Bottom-up is surely controversial, so I will not speak more ;-)

I remember, Alex Stepanov once gave a lecture here at our Adobe office, and there was a fair bit of discussion around this point. I actually cannot remember which, if any, side he spoke for. However, see page 5 of his &lt;a href="http://www.stepanovpapers.com/notes.pdf" rel="nofollow"&gt;notes on programming&lt;/a&gt;. There, he tries to be promoting a view alternative to top-down design, perhaps mostly to encourage the reader to appreciate the "bottom" of software -- data-structures, algorithms and complexity -- stuff which too many "pattern-oriented" designs consider secondary. When phrased like that, I personally, am all for the bottom of it!</description>
		<content:encoded><![CDATA[<p>Thanks for the comment, Sam.</p>
<p>While the book doesn&#8217;t ever mention &#8220;functional programming&#8221;, many of K&#038;P&#8217;s suggestions, as you said, work nicely with FP:</p>
<p>Functions in FP tend to be naturally small: It is interesting to ponder what makes programming with FP-flavor lead naturally to smaller, shorter, more concise functions. It could well be that this is my personal feeling because I&#8217;ve never really programmed &#8220;real-world&#8221; programs to solve &#8220;real&#8221; problems. But I suspect it is more generally true: Functions in imperative languages tend to be longer.</p>
<p>Functions in FP are more loosely coupled. Again, this is arguable. But I think using lists or property-bags as common data-structures leads to looser coupling.</p>
<p>And of course, FP eliminates a whole variety of errors related to order of assignment, uninitialized variables, using evil control structures&#8230; <i>FP is good</i>.</p>
<p>As for top-down design, &#8220;successive refinement&#8221; does seem to be a good way to <i>understand</i> a solution, if not necessarily <i>design</i> one &#8212; it helps understand the interactions between the players before delving in details on how each one does its job.</p>
<p>Perhaps top-down vs. bottom-up is like this: Which do you do first when coding or defining a recursive function &#8212; code the &#8220;recursion part&#8221; first, or, code the base case first? Most times, I think, it is more natural do the &#8220;recursion part&#8221; first, if only because it helps clarify what the base cases should be &#8212; precisely the cases for which it makes no further sense to subdivide the problem to conquer it!</p>
<p>But Top-down vs. Bottom-up is surely controversial, so I will not speak more ;-)</p>
<p>I remember, Alex Stepanov once gave a lecture here at our Adobe office, and there was a fair bit of discussion around this point. I actually cannot remember which, if any, side he spoke for. However, see page 5 of his <a href="http://www.stepanovpapers.com/notes.pdf" rel="nofollow">notes on programming</a>. There, he tries to be promoting a view alternative to top-down design, perhaps mostly to encourage the reader to appreciate the &#8220;bottom&#8221; of software &#8212; data-structures, algorithms and complexity &#8212; stuff which too many &#8220;pattern-oriented&#8221; designs consider secondary. When phrased like that, I personally, am all for the bottom of it!</p>
<img src="http://feeds.feedburner.com/~r/CommentsForAshutoshMehraBlog/~4/IwvsjROKmRU" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/comment-page-1/#comment-993</feedburner:origLink></item>
	<item>
		<title>Comment on Kernighan &amp; Plauger on Programming Style by Sam Martin</title>
		<link>http://feedproxy.google.com/~r/CommentsForAshutoshMehraBlog/~3/pY0TsZAr29E/</link>
		<dc:creator>Sam Martin</dc:creator>
		<pubDate>Fri, 10 Jul 2009 11:41:10 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=556#comment-992</guid>
		<description>I think it's interesting that most of the extracts lean towards following a functional style of programming over an imperative style. Does the book make any explicit mention of functional programming languages?

Most points sound pretty decent and uncontroversial. I'm not sure about the top-down one though! This kind of approach works a lot of time, but not all the time. Sometimes it's actually better to build things bottom up, or do a mix of both. I think it depends more on what the problem is.

Thanks,
Sam</description>
		<content:encoded><![CDATA[<p>I think it&#8217;s interesting that most of the extracts lean towards following a functional style of programming over an imperative style. Does the book make any explicit mention of functional programming languages?</p>
<p>Most points sound pretty decent and uncontroversial. I&#8217;m not sure about the top-down one though! This kind of approach works a lot of time, but not all the time. Sometimes it&#8217;s actually better to build things bottom up, or do a mix of both. I think it depends more on what the problem is.</p>
<p>Thanks,<br />
Sam</p>
<img src="http://feeds.feedburner.com/~r/CommentsForAshutoshMehraBlog/~4/pY0TsZAr29E" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/comment-page-1/#comment-992</feedburner:origLink></item>
	<item>
		<title>Comment on Kernighan &amp; Plauger on Programming Style by Ashutosh</title>
		<link>http://feedproxy.google.com/~r/CommentsForAshutoshMehraBlog/~3/YTwPjt1c5Ng/</link>
		<dc:creator>Ashutosh</dc:creator>
		<pubDate>Fri, 03 Jul 2009 17:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://ashutoshmehra.net/blog/?p=556#comment-989</guid>
		<description>Thanks for the comment, Radu. 

Yes, I remember flipping through that book some years ago -- it did have a similar flavor. 

Kernighan's books are still awesome if only because they are short, sweet, to the point, and, of course, still relevant -- one small reason I prefer them over, say, &lt;i&gt;&lt;a href="http://www.amazon.com/gp/product/0735619670?ie=UTF8&amp;tag=ashmehblo-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0735619670" rel="nofollow"&gt;Code Complete&lt;/a&gt;&lt;/i&gt;.

&lt;i&gt;Code Complete&lt;/i&gt; too, is highly acclaimed, on similar lines, and more current. But it's a much larger work (~250 vs. ~1000 pages), and studying it would take much more than a week (roughly the time I took to finish &lt;i&gt;Programming Style&lt;/i&gt;).</description>
		<content:encoded><![CDATA[<p>Thanks for the comment, Radu. </p>
<p>Yes, I remember flipping through that book some years ago &#8212; it did have a similar flavor. </p>
<p>Kernighan&#8217;s books are still awesome if only because they are short, sweet, to the point, and, of course, still relevant &#8212; one small reason I prefer them over, say, <i><a href="http://www.amazon.com/gp/product/0735619670?ie=UTF8&#038;tag=ashmehblo-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0735619670" rel="nofollow">Code Complete</a></i>.</p>
<p><i>Code Complete</i> too, is highly acclaimed, on similar lines, and more current. But it&#8217;s a much larger work (~250 vs. ~1000 pages), and studying it would take much more than a week (roughly the time I took to finish <i>Programming Style</i>).</p>
<img src="http://feeds.feedburner.com/~r/CommentsForAshutoshMehraBlog/~4/YTwPjt1c5Ng" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://ashutoshmehra.net/blog/2009/06/kernighan-plauger-programming-style/comment-page-1/#comment-989</feedburner:origLink></item>
</channel>
</rss>
