<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	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"
	>
<channel>
	<title>Comments on: Bridge and torch puzzle</title>
	<atom:link href="http://www.aswinvanwoudenberg.com/index.php/2009/07/03/bridge-and-torch-puzzle/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aswinvanwoudenberg.com/index.php/2009/07/03/bridge-and-torch-puzzle/</link>
	<description>Software, math and other geeky stuff</description>
	<pubDate>Fri, 10 Sep 2010 19:12:43 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Nerisha</title>
		<link>http://www.aswinvanwoudenberg.com/index.php/2009/07/03/bridge-and-torch-puzzle/#comment-7495</link>
		<dc:creator>Nerisha</dc:creator>
		<pubDate>Thu, 03 Jun 2010 08:10:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.aswinvanwoudenberg.com/?p=240#comment-7495</guid>
		<description>Hi,

Has anyone solved this in C#, VB, or Delphi?</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Has anyone solved this in C#, VB, or Delphi?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin</title>
		<link>http://www.aswinvanwoudenberg.com/index.php/2009/07/03/bridge-and-torch-puzzle/#comment-6485</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Fri, 20 Nov 2009 18:44:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.aswinvanwoudenberg.com/?p=240#comment-6485</guid>
		<description>Goedenavond, I've been correcting Prolog homework and I think I've actually "corrected" your solution.. hehe. If you're interested, what I gave as feedback was just that appending and then sorting is a bit more inefficient than just inserting it into the right spot in the first place:

zet_in(P, [P2&#124;Rest], [P2&#124;Rest2]) :-
 P @&#62; P2,
 !,
 zet_in(P, Rest, Rest2).
zet_in(Person, Rest, [Person&#124;Rest]).

(At least if you want to make this general on to longer lists, and especially if sort/2 were quicksort, but I think in SWI it's merge sort.) You could of course avoid the problem by instead having only one list, something like:

[-1, 2, -5, 10] 

and having a flip1(L,L2,Sign) predicate that traverses the list and flips one of the number that have the same sign as Sign and then stops, so that 
flip1([-1, 2, -5, 10], [  1, 2, -5, 10], -1) and
flip1([-1, 2, -5, 10], [-1, 2,   5, 10], -1) are true; 
flip2 does the same thing for two numbers but calls flip1 on the tail list in its base case. 

(Not all my students are so well versed in the ways of Google though. One of them actually gave me a solution where the list of people was represented as a bit set, with breadth first search on difference lists...)</description>
		<content:encoded><![CDATA[<p>Goedenavond, I&#8217;ve been correcting Prolog homework and I think I&#8217;ve actually &#8220;corrected&#8221; your solution.. hehe. If you&#8217;re interested, what I gave as feedback was just that appending and then sorting is a bit more inefficient than just inserting it into the right spot in the first place:</p>
<p>zet_in(P, [P2|Rest], [P2|Rest2]) :-<br />
 P @&gt; P2,<br />
 !,<br />
 zet_in(P, Rest, Rest2).<br />
zet_in(Person, Rest, [Person|Rest]).</p>
<p>(At least if you want to make this general on to longer lists, and especially if sort/2 were quicksort, but I think in SWI it&#8217;s merge sort.) You could of course avoid the problem by instead having only one list, something like:</p>
<p>[-1, 2, -5, 10] </p>
<p>and having a flip1(L,L2,Sign) predicate that traverses the list and flips one of the number that have the same sign as Sign and then stops, so that<br />
flip1([-1, 2, -5, 10], [  1, 2, -5, 10], -1) and<br />
flip1([-1, 2, -5, 10], [-1, 2,   5, 10], -1) are true;<br />
flip2 does the same thing for two numbers but calls flip1 on the tail list in its base case. </p>
<p>(Not all my students are so well versed in the ways of Google though. One of them actually gave me a solution where the list of people was represented as a bit set, with breadth first search on difference lists&#8230;)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
