<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Rail-Fence Cipher</title>
	<atom:link href="http://programmingpraxis.com/2009/03/31/rail-fence-cipher/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2009/03/31/rail-fence-cipher/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Sat, 11 Feb 2012 09:48:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jan Van lent</title>
		<link>http://programmingpraxis.com/2009/03/31/rail-fence-cipher/#comment-291</link>
		<dc:creator><![CDATA[Jan Van lent]]></dc:creator>
		<pubDate>Mon, 06 Jul 2009 23:08:49 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=350#comment-291</guid>
		<description><![CDATA[Common Lisp solution at &lt;a href=&quot;http://paste.lisp.org/display/83135&quot; rel=&quot;nofollow&quot;&gt;http://paste.lisp.org/display/83135&lt;/a&gt;.]]></description>
		<content:encoded><![CDATA[<p>Common Lisp solution at <a href="http://paste.lisp.org/display/83135" rel="nofollow">http://paste.lisp.org/display/83135</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Programming Praxis &#8211; Double Transposition Cipher &#171; Bonsai Code</title>
		<link>http://programmingpraxis.com/2009/03/31/rail-fence-cipher/#comment-144</link>
		<dc:creator><![CDATA[Programming Praxis &#8211; Double Transposition Cipher &#171; Bonsai Code]]></dc:creator>
		<pubDate>Sat, 30 May 2009 15:49:22 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=350#comment-144</guid>
		<description><![CDATA[[...] up we have zipSort, which I also used in the Rail-Fence Cipher [...]]]></description>
		<content:encoded><![CDATA[<p>[...] up we have zipSort, which I also used in the Rail-Fence Cipher [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: programmingpraxis</title>
		<link>http://programmingpraxis.com/2009/03/31/rail-fence-cipher/#comment-115</link>
		<dc:creator><![CDATA[programmingpraxis]]></dc:creator>
		<pubDate>Fri, 22 May 2009 04:50:11 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=350#comment-115</guid>
		<description><![CDATA[Posted on behalf of Matthias Felleisen:

&quot;I have finally found some time to write up &lt;a href=&quot;http://www.ccs.neu.edu/home/matthias/essays/crypt.html&quot; rel=&quot;nofollow&quot;&gt;my version of the story&lt;/a&gt; which only starts with the post here as a way to explain the idea in a first-semester FP course -- with design principles.

In contrast to the Haskell solution, mine is linear. If a linear purely FP solution exists, I&#039;d like to know.&quot;]]></description>
		<content:encoded><![CDATA[<p>Posted on behalf of Matthias Felleisen:</p>
<p>&#8220;I have finally found some time to write up <a href="http://www.ccs.neu.edu/home/matthias/essays/crypt.html" rel="nofollow">my version of the story</a> which only starts with the post here as a way to explain the idea in a first-semester FP course &#8212; with design principles.</p>
<p>In contrast to the Haskell solution, mine is linear. If a linear purely FP solution exists, I&#8217;d like to know.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luis Sergio Oliveira</title>
		<link>http://programmingpraxis.com/2009/03/31/rail-fence-cipher/#comment-110</link>
		<dc:creator><![CDATA[Luis Sergio Oliveira]]></dc:creator>
		<pubDate>Sun, 17 May 2009 17:03:31 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=350#comment-110</guid>
		<description><![CDATA[Hi,

my solution in Common Lisp, including some tests is here: http://lisp.pastebin.com/f27e23d44.

Notice that I haven&#039;t followed the algorithm proposed in your solution which is indeed very interesting...

Thanks for the problem,

Luis]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>my solution in Common Lisp, including some tests is here: <a href="http://lisp.pastebin.com/f27e23d44" rel="nofollow">http://lisp.pastebin.com/f27e23d44</a>.</p>
<p>Notice that I haven&#8217;t followed the algorithm proposed in your solution which is indeed very interesting&#8230;</p>
<p>Thanks for the problem,</p>
<p>Luis</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FalconNL</title>
		<link>http://programmingpraxis.com/2009/03/31/rail-fence-cipher/#comment-49</link>
		<dc:creator><![CDATA[FalconNL]]></dc:creator>
		<pubDate>Thu, 02 Apr 2009 09:40:24 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=350#comment-49</guid>
		<description><![CDATA[Updated version that I believe should run in O(n log n) for both rail and derail (rail was O(n^2) in the previous version):

[sourcecode lang=&#039;css&#039;]
import Data.List
import GHC.Exts

main = do print $ rail 4 &quot;PROGRAMMING PRAXIS&quot;
          print . derail 4 $ rail 4 &quot;PROGRAMMING PRAXIS&quot;

rail :: Int -&gt; [a] -&gt; [a]
rail n = zipSort (cycle $ [1..n] ++ [n-1,n-2..2])

derail :: Ord a =&gt; Int -&gt; [a] -&gt; [a]
derail n s = zipSort (rail n $ zipWith const [0..] s) s

zipSort :: Ord a =&gt; [a] -&gt; [b] -&gt; [b]
zipSort ks = map snd . sortWith fst . zip ks
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>Updated version that I believe should run in O(n log n) for both rail and derail (rail was O(n^2) in the previous version):</p>
<pre class="brush: css;">
import Data.List
import GHC.Exts

main = do print $ rail 4 &quot;PROGRAMMING PRAXIS&quot;
          print . derail 4 $ rail 4 &quot;PROGRAMMING PRAXIS&quot;

rail :: Int -&gt; [a] -&gt; [a]
rail n = zipSort (cycle $ [1..n] ++ [n-1,n-2..2])

derail :: Ord a =&gt; Int -&gt; [a] -&gt; [a]
derail n s = zipSort (rail n $ zipWith const [0..] s) s

zipSort :: Ord a =&gt; [a] -&gt; [b] -&gt; [b]
zipSort ks = map snd . sortWith fst . zip ks
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: matthias</title>
		<link>http://programmingpraxis.com/2009/03/31/rail-fence-cipher/#comment-48</link>
		<dc:creator><![CDATA[matthias]]></dc:creator>
		<pubDate>Wed, 01 Apr 2009 15:37:18 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=350#comment-48</guid>
		<description><![CDATA[Oops, fence is a two-liner in PLT Scheme, too: 

(define (fence s n)
  (define is (shared ((x (append (range 1 n) (range (- n 1) 2) x))) x))
  (map first (sort2 (for/list ((c s) (i (in-list is))) (list c i)))))]]></description>
		<content:encoded><![CDATA[<p>Oops, fence is a two-liner in PLT Scheme, too: </p>
<p>(define (fence s n)<br />
  (define is (shared ((x (append (range 1 n) (range (- n 1) 2) x))) x))<br />
  (map first (sort2 (for/list ((c s) (i (in-list is))) (list c i)))))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matthias</title>
		<link>http://programmingpraxis.com/2009/03/31/rail-fence-cipher/#comment-47</link>
		<dc:creator><![CDATA[matthias]]></dc:creator>
		<pubDate>Wed, 01 Apr 2009 14:31:10 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=350#comment-47</guid>
		<description><![CDATA[FalconNL, your design turns the solution into
&quot;Fortran&quot;, using indexes into lists (of chars) 
where a generative-recursion design (for freshmen) 
 exposes the waves as they come about. 

Then again, you demonstrate how temporary
laziness in &#039;waves&#039; is a useful tool. Let me show
you how temporary, invisible assignments accomplish the exact same purpose. 

;; [Listof X] Nat -&gt; [Listof X]
;;                                                      1   5    9           
;; 1 2 3 4 5 6 7 8 9 10 11  ==&gt;   2 4 6  8 10    ==&gt; 1 5 9 2 4 6 8 10 3 7 11 
;;                                                         3   7    11 

(check-expect (fence &#039;(1 2 3 4 5 6) 3) &#039;(1 5 2 4 6 3))
(check-expect (fence &#039;(1 2 3 4 5 6 7 8 9 10 11) 3) &#039;(1 5 9 2 4 6 8 10 3 7 11))

(define (fence s n)
  (define is (shared ((x (append (range 1 n) (range (- n 1) 2) x))) x))
  (define wv (for/list ((c s)) (begin0 (list c (car is)) (set! is (cdr is)))))
  (map first (sort2 wv)))]]></description>
		<content:encoded><![CDATA[<p>FalconNL, your design turns the solution into<br />
&#8220;Fortran&#8221;, using indexes into lists (of chars)<br />
where a generative-recursion design (for freshmen)<br />
 exposes the waves as they come about. </p>
<p>Then again, you demonstrate how temporary<br />
laziness in &#8216;waves&#8217; is a useful tool. Let me show<br />
you how temporary, invisible assignments accomplish the exact same purpose. </p>
<p>;; [Listof X] Nat -&gt; [Listof X]<br />
;;                                                      1   5    9<br />
;; 1 2 3 4 5 6 7 8 9 10 11  ==&gt;   2 4 6  8 10    ==&gt; 1 5 9 2 4 6 8 10 3 7 11<br />
;;                                                         3   7    11 </p>
<p>(check-expect (fence &#8216;(1 2 3 4 5 6) 3) &#8216;(1 5 2 4 6 3))<br />
(check-expect (fence &#8216;(1 2 3 4 5 6 7 8 9 10 11) 3) &#8216;(1 5 9 2 4 6 8 10 3 7 11))</p>
<p>(define (fence s n)<br />
  (define is (shared ((x (append (range 1 n) (range (- n 1) 2) x))) x))<br />
  (define wv (for/list ((c s)) (begin0 (list c (car is)) (set! is (cdr is)))))<br />
  (map first (sort2 wv)))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FalconNL</title>
		<link>http://programmingpraxis.com/2009/03/31/rail-fence-cipher/#comment-46</link>
		<dc:creator><![CDATA[FalconNL]]></dc:creator>
		<pubDate>Tue, 31 Mar 2009 15:06:37 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=350#comment-46</guid>
		<description><![CDATA[In Haskell:

[sourcecode lang=&#039;css&#039;]
import Data.List

main = do print $ rail 4 &quot;PROGRAMMING PRAXIS&quot;
          print . derail 4 $ rail 4 &quot;PROGRAMMING PRAXIS&quot;

rail :: Int -&gt; String -&gt; String
rail n s = map (s !!) $ waves n s
             
derail :: Int -&gt; String -&gt; String
derail n s = map snd . sort $ zip (waves n s) s

waves :: Int -&gt; String -&gt; [Int]
waves n = map snd . sort . zip (cycle $ [1..n] ++ [n-1,n-2..2]) . zipWith const [0..]
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>In Haskell:</p>
<pre class="brush: css;">
import Data.List

main = do print $ rail 4 &quot;PROGRAMMING PRAXIS&quot;
          print . derail 4 $ rail 4 &quot;PROGRAMMING PRAXIS&quot;

rail :: Int -&gt; String -&gt; String
rail n s = map (s !!) $ waves n s

derail :: Int -&gt; String -&gt; String
derail n s = map snd . sort $ zip (waves n s) s

waves :: Int -&gt; String -&gt; [Int]
waves n = map snd . sort . zip (cycle $ [1..n] ++ [n-1,n-2..2]) . zipWith const [0..]
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>

