<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to solve the Dodgson’s Doublets Puzzle in SQL</title>
	<atom:link href="http://oraqa.com/2010/06/02/how-to-solve-the-dodgson%e2%80%99s-doublets-puzzle-in-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://oraqa.com/2010/06/02/how-to-solve-the-dodgson%e2%80%99s-doublets-puzzle-in-sql/</link>
	<description>Oracle Question and Answer</description>
	<lastBuildDate>Mon, 19 Dec 2011 14:21:07 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: newkid</title>
		<link>http://oraqa.com/2010/06/02/how-to-solve-the-dodgson%e2%80%99s-doublets-puzzle-in-sql/comment-page-1/#comment-275</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Fri, 25 Jun 2010 13:47:45 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=491#comment-275</guid>
		<description>WITH w AS (
SELECT word
      ,UPPER(SUBSTR(word,rn,1)) c 
      ,rn
  FROM dictionary, (SELECT ROWNUM rn FROM DUAL CONNECT BY ROWNUM&lt;=(SELECT MAX(LENGTH(word)) FROM dictionary))
WHERE rn&lt;=LENGTH(word)
)
,l AS (SELECT w1.word w1,w2.word w2
  FROM w w1,w w2
WHERE LENGTH(w1.word)=LENGTH(w2.word) AND w1.rn=w2.rn
       AND w1.word&lt;&gt;w2.word
GROUP BY w1.word,w2.word
HAVING COUNT(CASE WHEN w1.c=w2.c THEN 1 END)=MAX(LENGTH(w1.word))-1
)
SELECT *
  FROM (
SELECT SYS_CONNECT_BY_PATH(w1,&#039;,&#039;)&#124;&#124;&#039;,&#039;&#124;&#124;:end_str
FROM l
WHERE UPPER(w2) = UPPER(:end_str)
START WITH UPPER(w1) = UPPER(:begin_str)
CONNECT BY NOCYCLE w1 = PRIOR w2 AND UPPER(PRIOR w2) != UPPER(:end_str)
ORDER BY LEVEL
)
WHERE ROWNUM=1;


SYS_CONNECT_BY_PATH(W1,&#039;,&#039;)&#124;&#124;&#039;,&#039;&#124;&#124;:END_STR
-------------------------------------------------
,HEAD,heal,teal,tell,tall,tail</description>
		<content:encoded><![CDATA[<p>WITH w AS (<br />
SELECT word<br />
      ,UPPER(SUBSTR(word,rn,1)) c<br />
      ,rn<br />
  FROM dictionary, (SELECT ROWNUM rn FROM DUAL CONNECT BY ROWNUM&lt;=(SELECT MAX(LENGTH(word)) FROM dictionary))<br />
WHERE rn&lt;=LENGTH(word)<br />
)<br />
,l AS (SELECT w1.word w1,w2.word w2<br />
  FROM w w1,w w2<br />
WHERE LENGTH(w1.word)=LENGTH(w2.word) AND w1.rn=w2.rn<br />
       AND w1.word&lt;&gt;w2.word<br />
GROUP BY w1.word,w2.word<br />
HAVING COUNT(CASE WHEN w1.c=w2.c THEN 1 END)=MAX(LENGTH(w1.word))-1<br />
)<br />
SELECT *<br />
  FROM (<br />
SELECT SYS_CONNECT_BY_PATH(w1,&#8217;,')||&#8217;,'||:end_str<br />
FROM l<br />
WHERE UPPER(w2) = UPPER(:end_str)<br />
START WITH UPPER(w1) = UPPER(:begin_str)<br />
CONNECT BY NOCYCLE w1 = PRIOR w2 AND UPPER(PRIOR w2) != UPPER(:end_str)<br />
ORDER BY LEVEL<br />
)<br />
WHERE ROWNUM=1;</p>
<p>SYS_CONNECT_BY_PATH(W1,&#8217;,')||&#8217;,'||:END_STR<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
,HEAD,heal,teal,tell,tall,tail</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: newkid</title>
		<link>http://oraqa.com/2010/06/02/how-to-solve-the-dodgson%e2%80%99s-doublets-puzzle-in-sql/comment-page-1/#comment-274</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Thu, 24 Jun 2010 22:09:03 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=491#comment-274</guid>
		<description>&lt;pre&gt;
WITH w AS (
SELECT word
      ,UPPER(SUBSTR(word,rn,1)) c
      ,rn
  FROM dictionary, (SELECT ROWNUM rn FROM DUAL CONNECT BY ROWNUM&lt;=(SELECT MAX(LENGTH(word)) FROM dictionary))
 WHERE rn&lt;=LENGTH(word)
)
,l AS (SELECT w1.word w1,w2.word w2
  FROM w w1,w w2
 WHERE LENGTH(w1.word)=LENGTH(w2.word) AND w1.rn=w2.rn
       AND w1.word != w2.word
GROUP BY w1.word,w2.word
HAVING COUNT(CASE WHEN w1.c=w2.c THEN 1 END)=MAX(LENGTH(w1.word))-1
)
SELECT *
  FROM (
SELECT SYS_CONNECT_BY_PATH(w1,&#039;,&#039;)&#124;&#124;&#039;,&#039;&#124;&#124;:end_str
 FROM l
WHERE UPPER(w2) = UPPER(:end_str)
 START WITH UPPER(w1) = UPPER(:begin_str)
CONNECT BY NOCYCLE w1 = PRIOR w2 AND UPPER(PRIOR w2) != UPPER(:end_str)
ORDER BY LEVEL
)
WHERE ROWNUM=1;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre>
WITH w AS (
SELECT word
      ,UPPER(SUBSTR(word,rn,1)) c
      ,rn
  FROM dictionary, (SELECT ROWNUM rn FROM DUAL CONNECT BY ROWNUM&lt;=(SELECT MAX(LENGTH(word)) FROM dictionary))
 WHERE rn&lt;=LENGTH(word)
)
,l AS (SELECT w1.word w1,w2.word w2
  FROM w w1,w w2
 WHERE LENGTH(w1.word)=LENGTH(w2.word) AND w1.rn=w2.rn
       AND w1.word != w2.word
GROUP BY w1.word,w2.word
HAVING COUNT(CASE WHEN w1.c=w2.c THEN 1 END)=MAX(LENGTH(w1.word))-1
)
SELECT *
  FROM (
SELECT SYS_CONNECT_BY_PATH(w1,&#039;,&#039;)||&#039;,&#039;||:end_str
 FROM l
WHERE UPPER(w2) = UPPER(:end_str)
 START WITH UPPER(w1) = UPPER(:begin_str)
CONNECT BY NOCYCLE w1 = PRIOR w2 AND UPPER(PRIOR w2) != UPPER(:end_str)
ORDER BY LEVEL
)
WHERE ROWNUM=1;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: newkid</title>
		<link>http://oraqa.com/2010/06/02/how-to-solve-the-dodgson%e2%80%99s-doublets-puzzle-in-sql/comment-page-1/#comment-273</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Thu, 24 Jun 2010 22:07:33 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=491#comment-273</guid>
		<description>&lt;pre&gt;
WITH w AS (
SELECT word
      ,UPPER(SUBSTR(word,rn,1)) c 
      ,rn
  FROM dictionary, (SELECT ROWNUM rn FROM DUAL CONNECT BY ROWNUM&lt;=(SELECT MAX(LENGTH(word)) FROM dictionary))
 WHERE rn&lt;=LENGTH(word)
)
,l AS (SELECT w1.word w1,w2.word w2
  FROM w w1,w w2
 WHERE LENGTH(w1.word)=LENGTH(w2.word) AND w1.rn=w2.rn
       AND w1.word != w2.word
GROUP BY w1.word,w2.word
HAVING COUNT(CASE WHEN w1.c=w2.c THEN 1 END)=MAX(LENGTH(w1.word))-1
)
SELECT *
  FROM (
SELECT SYS_CONNECT_BY_PATH(w1,&#039;,&#039;)&#124;&#124;&#039;,&#039;&#124;&#124;:end_str
 FROM l
WHERE UPPER(w2) = UPPER(:end_str)
 START WITH UPPER(w1) = UPPER(:begin_str)
CONNECT BY NOCYCLE w1 = PRIOR w2 AND UPPER(PRIOR w2) != UPPER(:end_str)
ORDER BY LEVEL
)
WHERE ROWNUM=1;


SYS_CONNECT_BY_PATH(W1,&#039;,&#039;)&#124;&#124;&#039;,&#039;&#124;&#124;:END_STR
-------------------------------------------------
,HEAD,heal,teal,tell,tall,tail
 &lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre>
WITH w AS (
SELECT word
      ,UPPER(SUBSTR(word,rn,1)) c
      ,rn
  FROM dictionary, (SELECT ROWNUM rn FROM DUAL CONNECT BY ROWNUM&lt;=(SELECT MAX(LENGTH(word)) FROM dictionary))
 WHERE rn&lt;=LENGTH(word)
)
,l AS (SELECT w1.word w1,w2.word w2
  FROM w w1,w w2
 WHERE LENGTH(w1.word)=LENGTH(w2.word) AND w1.rn=w2.rn
       AND w1.word != w2.word
GROUP BY w1.word,w2.word
HAVING COUNT(CASE WHEN w1.c=w2.c THEN 1 END)=MAX(LENGTH(w1.word))-1
)
SELECT *
  FROM (
SELECT SYS_CONNECT_BY_PATH(w1,&#039;,&#039;)||&#039;,&#039;||:end_str
 FROM l
WHERE UPPER(w2) = UPPER(:end_str)
 START WITH UPPER(w1) = UPPER(:begin_str)
CONNECT BY NOCYCLE w1 = PRIOR w2 AND UPPER(PRIOR w2) != UPPER(:end_str)
ORDER BY LEVEL
)
WHERE ROWNUM=1;

SYS_CONNECT_BY_PATH(W1,&#039;,&#039;)||&#039;,&#039;||:END_STR
-------------------------------------------------
,HEAD,heal,teal,tell,tall,tail
 </pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: newkid</title>
		<link>http://oraqa.com/2010/06/02/how-to-solve-the-dodgson%e2%80%99s-doublets-puzzle-in-sql/comment-page-1/#comment-269</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Thu, 24 Jun 2010 20:41:57 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=491#comment-269</guid>
		<description>oops...I missed that one!</description>
		<content:encoded><![CDATA[<p>oops&#8230;I missed that one!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Zhou</title>
		<link>http://oraqa.com/2010/06/02/how-to-solve-the-dodgson%e2%80%99s-doublets-puzzle-in-sql/comment-page-1/#comment-266</link>
		<dc:creator>Frank Zhou</dc:creator>
		<pubDate>Thu, 24 Jun 2010 19:22:14 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=491#comment-266</guid>
		<description>Hi NewKid,

Please read all the rules carefully.

The letters must not be interchanged among themselves,
**** but each must keep to its own place ***

The translate can not guarantee the &quot;position&quot; of the letters.

Thanks for give this problem a try !

Frank</description>
		<content:encoded><![CDATA[<p>Hi NewKid,</p>
<p>Please read all the rules carefully.</p>
<p>The letters must not be interchanged among themselves,<br />
**** but each must keep to its own place ***</p>
<p>The translate can not guarantee the &#8220;position&#8221; of the letters.</p>
<p>Thanks for give this problem a try !</p>
<p>Frank</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: newkid</title>
		<link>http://oraqa.com/2010/06/02/how-to-solve-the-dodgson%e2%80%99s-doublets-puzzle-in-sql/comment-page-1/#comment-257</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Thu, 24 Jun 2010 17:26:22 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=491#comment-257</guid>
		<description>Forgot to check the length in connect by:
&lt;pre&gt;
SELECT chain
  FROM (
SELECT SYS_CONNECT_BY_PATH(word,&#039;-&gt;&#039;) chain,LEVEL lvl,word
  FROM dictionary 
 START WITH UPPER(word) = UPPER(:begin_str)
 CONNECT BY NOCYCLE wordPRIOR word AND LENGTH(TRANSLATE(UPPER(word),&#039;$&#039;&#124;&#124;UPPER(PRIOR word),&#039;$&#039;))=1
         AND LENGTH(word) = LENGTH(PRIOR word)
)
WHERE UPPER(word) = UPPER(:end_str);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Forgot to check the length in connect by:</p>
<pre>
SELECT chain
  FROM (
SELECT SYS_CONNECT_BY_PATH(word,'-&gt;') chain,LEVEL lvl,word
  FROM dictionary
 START WITH UPPER(word) = UPPER(:begin_str)
 CONNECT BY NOCYCLE wordPRIOR word AND LENGTH(TRANSLATE(UPPER(word),'$'||UPPER(PRIOR word),'$'))=1
         AND LENGTH(word) = LENGTH(PRIOR word)
)
WHERE UPPER(word) = UPPER(:end_str);
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: newkid</title>
		<link>http://oraqa.com/2010/06/02/how-to-solve-the-dodgson%e2%80%99s-doublets-puzzle-in-sql/comment-page-1/#comment-256</link>
		<dc:creator>newkid</dc:creator>
		<pubDate>Thu, 24 Jun 2010 17:19:57 +0000</pubDate>
		<guid isPermaLink="false">http://oraqa.com/?p=491#comment-256</guid>
		<description>&lt;pre&gt;
SELECT chain
  FROM (
SELECT SYS_CONNECT_BY_PATH(word,&#039;-&gt;&#039;) chain,LEVEL lvl,word
  FROM dictionary 
 START WITH UPPER(word) = UPPER(:begin_str)
 CONNECT BY NOCYCLE wordPRIOR word AND LENGTH(TRANSLATE(UPPER(word),&#039;$&#039;&#124;&#124;UPPER(PRIOR word),&#039;$&#039;))=1
)
WHERE UPPER(word) = UPPER(:end_str);

CHAIN
-------------------------------------------------------------
-&gt;HEAD-&gt;heal-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tall-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tall-&gt;tell-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tall-&gt;toll-&gt;tell-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;teal-&gt;toll-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;teal-&gt;toll-&gt;tell-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;tall-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;teal-&gt;toll-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;toll-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;toll-&gt;tall-&gt;teal-&gt;TAIL
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre>
SELECT chain
  FROM (
SELECT SYS_CONNECT_BY_PATH(word,'-&gt;') chain,LEVEL lvl,word
  FROM dictionary
 START WITH UPPER(word) = UPPER(:begin_str)
 CONNECT BY NOCYCLE wordPRIOR word AND LENGTH(TRANSLATE(UPPER(word),'$'||UPPER(PRIOR word),'$'))=1
)
WHERE UPPER(word) = UPPER(:end_str);

CHAIN
-------------------------------------------------------------
-&gt;HEAD-&gt;heal-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tall-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tall-&gt;tell-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tall-&gt;toll-&gt;tell-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;teal-&gt;toll-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;teal-&gt;toll-&gt;tell-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;tall-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;teal-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;teal-&gt;toll-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;toll-&gt;tall-&gt;TAIL
-&gt;HEAD-&gt;heal-&gt;tell-&gt;toll-&gt;tall-&gt;teal-&gt;TAIL
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

