<?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: Programming Challenge: Crypt Kicker</title>
	<atom:link href="http://mikael.jansson.be/log/programming-challenge-crypt-kicker/feed" rel="self" type="application/rss+xml" />
	<link>http://mikael.jansson.be/log/programming-challenge-crypt-kicker</link>
	<description>The views of a hacker, hobby chef &#38; adrenaline junkie.</description>
	<pubDate>Fri, 30 Jul 2010 16:05:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Alex</title>
		<link>http://mikael.jansson.be/log/programming-challenge-crypt-kicker/comment-page-1#comment-32358</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Wed, 24 Jun 2009 21:16:27 +0000</pubDate>
		<guid isPermaLink="false">http://mikael.jansson.be/journal/2009/02/programming-challenge-crypt-kicker#comment-32358</guid>
		<description>http://paste.lisp.org/display/82457

&lt;pre&gt;&lt;br /&gt;
(defun unify-letters (letter-map letter1 letter2)&lt;br /&gt;
&#160;&#160;(char= letter2 (internhash letter-map letter1 letter2)))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun unify-words (word1 word2 letter-map)&lt;br /&gt;
&#160;&#160;(when (= (length word1) (length word2))&lt;br /&gt;
&#160;&#160;&#160;&#160;(let ((map (copy-hash-table letter-map)))&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;(values (every (sp #&#039;unify-letters map _ _) word1 word2) map))))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun unify (word1 word2 letter-map)&lt;br /&gt;
&#160;&#160;(multiple-value-bind (succeded-p map) (unify-words word1 word2 letter-map)&lt;br /&gt;
&#160;&#160;&#160;&#160;(when succeded-p&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;(maphash (sp #&#039;internhash letter-map _ _) map))))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun solve (dictionary input)&lt;br /&gt;
&#160;&#160;(let ((map (hash)))&lt;br /&gt;
&#160;&#160;&#160;&#160;(loop for w1 in input&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160; do (loop for w2 in dictionary&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160; do (unify w1 w2 map)))&lt;br /&gt;
&#160;&#160;&#160;&#160;map))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun purify (input)&lt;br /&gt;
&#160;&#160;(sort (remove-duplicates (copy-list input) :test #&#039;string=) #&#039;string&gt;))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun decrypt (dictionary input)&lt;br /&gt;
&#160;&#160;(let ((map (solve dictionary input)))&lt;br /&gt;
&#160;&#160;&#160;&#160;(mapcar (lambda (word) (map &#039;string (sp #&#039;gethash _ map) word)) input)))&lt;br /&gt;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p><a href="http://paste.lisp.org/display/82457" rel="nofollow">http://paste.lisp.org/display/82457</a></p>
<pre>
(defun unify-letters (letter-map letter1 letter2)
&nbsp;&nbsp;(char= letter2 (internhash letter-map letter1 letter2)))
&nbsp;
(defun unify-words (word1 word2 letter-map)
&nbsp;&nbsp;(when (= (length word1) (length word2))
&nbsp;&nbsp;&nbsp;&nbsp;(let ((map (copy-hash-table letter-map)))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(values (every (sp #&#039;unify-letters map _ _) word1 word2) map))))
&nbsp;
(defun unify (word1 word2 letter-map)
&nbsp;&nbsp;(multiple-value-bind (succeded-p map) (unify-words word1 word2 letter-map)
&nbsp;&nbsp;&nbsp;&nbsp;(when succeded-p
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(maphash (sp #&#039;internhash letter-map _ _) map))))
&nbsp;
(defun solve (dictionary input)
&nbsp;&nbsp;(let ((map (hash)))
&nbsp;&nbsp;&nbsp;&nbsp;(loop for w1 in input
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do (loop for w2 in dictionary
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do (unify w1 w2 map)))
&nbsp;&nbsp;&nbsp;&nbsp;map))
&nbsp;
(defun purify (input)
&nbsp;&nbsp;(sort (remove-duplicates (copy-list input) :test #&#039;string=) #&#039;string&amp;gt;))
&nbsp;
(defun decrypt (dictionary input)
&nbsp;&nbsp;(let ((map (solve dictionary input)))
&nbsp;&nbsp;&nbsp;&nbsp;(mapcar (lambda (word) (map &#039;string (sp #&#039;gethash _ map) word)) input)))
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikael Jansson &#187; Blog Archive &#187; Jag, en arg LCHF-människa?</title>
		<link>http://mikael.jansson.be/log/programming-challenge-crypt-kicker/comment-page-1#comment-29659</link>
		<dc:creator>Mikael Jansson &#187; Blog Archive &#187; Jag, en arg LCHF-människa?</dc:creator>
		<pubDate>Thu, 05 Mar 2009 18:15:37 +0000</pubDate>
		<guid isPermaLink="false">http://mikael.jansson.be/journal/2009/02/programming-challenge-crypt-kicker#comment-29659</guid>
		<description>[...] Programming Challenge: Crypt Kicker [...]</description>
		<content:encoded><![CDATA[<p>[...] Programming Challenge: Crypt Kicker [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adeht</title>
		<link>http://mikael.jansson.be/log/programming-challenge-crypt-kicker/comment-page-1#comment-29087</link>
		<dc:creator>adeht</dc:creator>
		<pubDate>Thu, 05 Feb 2009 21:58:58 +0000</pubDate>
		<guid isPermaLink="false">http://mikael.jansson.be/journal/2009/02/programming-challenge-crypt-kicker#comment-29087</guid>
		<description>Hello again Mikael,

You missed a reference to the alphabet variable in the recursive call to find-mapping.

&lt;em&gt;Sorry! Thanks for noticing.
--Mikael&lt;/em&gt;</description>
		<content:encoded><![CDATA[<p>Hello again Mikael,</p>
<p>You missed a reference to the alphabet variable in the recursive call to find-mapping.</p>
<p><em>Sorry! Thanks for noticing.<br />
&#8211;Mikael</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adeht</title>
		<link>http://mikael.jansson.be/log/programming-challenge-crypt-kicker/comment-page-1#comment-29079</link>
		<dc:creator>adeht</dc:creator>
		<pubDate>Thu, 05 Feb 2009 12:00:24 +0000</pubDate>
		<guid isPermaLink="false">http://mikael.jansson.be/journal/2009/02/programming-challenge-crypt-kicker#comment-29079</guid>
		<description>Hey Mikael,

I don't mind at all.  Go ahead, and thanks for posting something interesting.</description>
		<content:encoded><![CDATA[<p>Hey Mikael,</p>
<p>I don&#8217;t mind at all.  Go ahead, and thanks for posting something interesting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikael Jansson</title>
		<link>http://mikael.jansson.be/log/programming-challenge-crypt-kicker/comment-page-1#comment-29077</link>
		<dc:creator>Mikael Jansson</dc:creator>
		<pubDate>Thu, 05 Feb 2009 11:51:13 +0000</pubDate>
		<guid isPermaLink="false">http://mikael.jansson.be/journal/2009/02/programming-challenge-crypt-kicker#comment-29077</guid>
		<description>adeht,

Looks good!

I did try the alist route (even had the same make-mapping as you did :)) when I was done with the hash-table version, but I was too tired to realize the fail-condition was as easy as comparing the cons pairs of the mapping. So I scrapped that and wrote a piece on what I had working.

Mind if I add the paste to your comment?</description>
		<content:encoded><![CDATA[<p>adeht,</p>
<p>Looks good!</p>
<p>I did try the alist route (even had the same make-mapping as you did :)) when I was done with the hash-table version, but I was too tired to realize the fail-condition was as easy as comparing the cons pairs of the mapping. So I scrapped that and wrote a piece on what I had working.</p>
<p>Mind if I add the paste to your comment?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adeht</title>
		<link>http://mikael.jansson.be/log/programming-challenge-crypt-kicker/comment-page-1#comment-29075</link>
		<dc:creator>adeht</dc:creator>
		<pubDate>Thu, 05 Feb 2009 11:10:32 +0000</pubDate>
		<guid isPermaLink="false">http://mikael.jansson.be/journal/2009/02/programming-challenge-crypt-kicker#comment-29075</guid>
		<description>Here's my quick (half an hour?) attempt.  Forgive the silly names, it's late :)

http://paste.lisp.org/display/74915


&lt;pre&gt;&lt;br /&gt;
(defparameter *dictionary*&lt;br /&gt;
&#160;&#160;&#039;(&#34;and&#34; &#34;dick&#34; &#34;jane&#34; &#34;puff&#34; &#34;spot&#34; &#34;yertle&#34;))&lt;br /&gt;
&#160;&lt;br /&gt;
(defparameter *input*&lt;br /&gt;
&#160;&#160;&#039;(&#34;bjvg&#34; &#34;xsb&#34; &#34;hxsn&#34; &#34;xsb&#34; &#34;qymm&#34; &#34;xsb&#34; &#34;rqat&#34; &#34;xsb&#34; &#34;pnetfn&#34;))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun solve ()&lt;br /&gt;
&#160;&#160;(decrypt *input* (find-mapping *input* *dictionary* (make-mapping))))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun find-mapping (input dictionary mapping)&lt;br /&gt;
&#160;&#160;(cond ((null mapping) nil)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;((complete-mapping-p mapping input) mapping)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;(t (let ((term (find-unmapped-term input mapping)))&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (some (lambda (word)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (find-mapping (remove term input :test #&#039;equal)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (remove word dictionary :test #&#039;equal)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (extend-mapping term word mapping)))&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; dictionary)))))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun complete-mapping-p (mapping input)&lt;br /&gt;
&#160;&#160;(every (lambda (term)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (every (lambda (c) (lookup-crypt c mapping)) term))&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; input))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun make-mapping () &#039;((t . t)))&lt;br /&gt;
(defun lookup-crypt (c mapping) (assoc c mapping))&lt;br /&gt;
(defun lookup-plain (c mapping) (rassoc c mapping))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun extend-mapping (term word mapping)&lt;br /&gt;
&#160;&#160;(when (= (length term) (length word))&lt;br /&gt;
&#160;&#160;&#160;&#160;(loop for tc across term&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for wc across word&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for m1 = (lookup-crypt tc mapping)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for m2 = (lookup-plain wc mapping)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;do (cond ((and m1 m2)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;(unless (eql m1 m2)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;(return-from extend-mapping nil)))&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ((or m1 m2)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;(return-from extend-mapping nil))&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (t (push (cons tc wc) mapping))))&lt;br /&gt;
&#160;&#160;&#160;&#160;mapping))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun find-unmapped-term (input mapping)&lt;br /&gt;
&#160;&#160;(find-if (lambda (term)&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (not (complete-mapping-p mapping (list term))))&lt;br /&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; input))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun decrypt (input mapping)&lt;br /&gt;
&#160;&#160;(when mapping&lt;br /&gt;
&#160;&#160;&#160;&#160;(mapcar (lambda (term) (decrypt-term term mapping)) input)))&lt;br /&gt;
&#160;&lt;br /&gt;
(defun decrypt-term (term mapping)&lt;br /&gt;
&#160;&#160;(map &#039;string (lambda (c) (cdr (lookup-crypt c mapping))) term))&lt;br /&gt;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Here&#8217;s my quick (half an hour?) attempt.  Forgive the silly names, it&#8217;s late :)</p>
<p><a href="http://paste.lisp.org/display/74915" rel="nofollow">http://paste.lisp.org/display/74915</a></p>
<pre>
(defparameter *dictionary*
&nbsp;&nbsp;&#039;(&quot;and&quot; &quot;dick&quot; &quot;jane&quot; &quot;puff&quot; &quot;spot&quot; &quot;yertle&quot;))
&nbsp;
(defparameter *input*
&nbsp;&nbsp;&#039;(&quot;bjvg&quot; &quot;xsb&quot; &quot;hxsn&quot; &quot;xsb&quot; &quot;qymm&quot; &quot;xsb&quot; &quot;rqat&quot; &quot;xsb&quot; &quot;pnetfn&quot;))
&nbsp;
(defun solve ()
&nbsp;&nbsp;(decrypt *input* (find-mapping *input* *dictionary* (make-mapping))))
&nbsp;
(defun find-mapping (input dictionary mapping)
&nbsp;&nbsp;(cond ((null mapping) nil)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((complete-mapping-p mapping input) mapping)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(t (let ((term (find-unmapped-term input mapping)))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (some (lambda (word)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (find-mapping (remove term input :test #&#039;equal)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (remove word dictionary :test #&#039;equal)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (extend-mapping term word mapping)))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dictionary)))))
&nbsp;
(defun complete-mapping-p (mapping input)
&nbsp;&nbsp;(every (lambda (term)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (every (lambda (c) (lookup-crypt c mapping)) term))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; input))
&nbsp;
(defun make-mapping () &#039;((t . t)))
(defun lookup-crypt (c mapping) (assoc c mapping))
(defun lookup-plain (c mapping) (rassoc c mapping))
&nbsp;
(defun extend-mapping (term word mapping)
&nbsp;&nbsp;(when (= (length term) (length word))
&nbsp;&nbsp;&nbsp;&nbsp;(loop for tc across term
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for wc across word
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for m1 = (lookup-crypt tc mapping)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for m2 = (lookup-plain wc mapping)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do (cond ((and m1 m2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(unless (eql m1 m2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(return-from extend-mapping nil)))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((or m1 m2)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(return-from extend-mapping nil))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (t (push (cons tc wc) mapping))))
&nbsp;&nbsp;&nbsp;&nbsp;mapping))
&nbsp;
(defun find-unmapped-term (input mapping)
&nbsp;&nbsp;(find-if (lambda (term)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (not (complete-mapping-p mapping (list term))))
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; input))
&nbsp;
(defun decrypt (input mapping)
&nbsp;&nbsp;(when mapping
&nbsp;&nbsp;&nbsp;&nbsp;(mapcar (lambda (term) (decrypt-term term mapping)) input)))
&nbsp;
(defun decrypt-term (term mapping)
&nbsp;&nbsp;(map &#039;string (lambda (c) (cdr (lookup-crypt c mapping))) term))
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
