<?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: Cellular Automata</title>
	<atom:link href="http://programmingpraxis.com/2009/05/15/cellular-automata/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmingpraxis.com/2009/05/15/cellular-automata/</link>
	<description>A collection of etudes, updated weekly, for the education and enjoyment of the savvy programmer</description>
	<lastBuildDate>Mon, 28 May 2012 03:30:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Devdhar</title>
		<link>http://programmingpraxis.com/2009/05/15/cellular-automata/#comment-4739</link>
		<dc:creator><![CDATA[Devdhar]]></dc:creator>
		<pubDate>Sun, 29 Apr 2012 22:07:24 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=573#comment-4739</guid>
		<description><![CDATA[MY SOLUTION :(U CAN SET NO OF GENERATIONS AND RULE NO.):

#include
using namespace std;
void binRev(int n,int arr[])
{
    int i=0;
    while(n&gt;0)
    {
              arr[i++]=(n%2);
              n=n/2;
    }
}   
void print(int arr[],int n)
{  
     int i=0;
     for(;i&lt;=n;i++)
     {
                   if(arr[i]==0)
                   cout&lt;&lt;&quot; &quot;;
                   else if(arr[i]==1)
                   cout&lt;&lt;&quot;#&quot;;
     }
     cout&lt;&lt;endl;
}
int main()
{
    int n;
    int store;
    int tri;
    int j;
    int i;
    cout&lt;&gt;n;
    n=n*2-1;
    int hash[n];
    for(j=0;j&lt;n;j++)
    hash[j]=0;
    hash[n/2]=1;
    int bin[8];
    for(j=0;j&lt;8;j++)
    bin[j]=0;
    cout&lt;&gt;store;
    binRev(store,bin);
    print(hash,n);
    for(j=0;j&lt;n/2-1;j++)
    {
                     store=hash[0];
           for(i=1;i&gt;n;    
}]]></description>
		<content:encoded><![CDATA[<p>MY SOLUTION :(U CAN SET NO OF GENERATIONS AND RULE NO.):</p>
<p>#include<br />
using namespace std;<br />
void binRev(int n,int arr[])<br />
{<br />
    int i=0;<br />
    while(n&gt;0)<br />
    {<br />
              arr[i++]=(n%2);<br />
              n=n/2;<br />
    }<br />
}<br />
void print(int arr[],int n)<br />
{<br />
     int i=0;<br />
     for(;i&lt;=n;i++)<br />
     {<br />
                   if(arr[i]==0)<br />
                   cout&lt;&lt;&quot; &quot;;<br />
                   else if(arr[i]==1)<br />
                   cout&lt;&lt;&quot;#&quot;;<br />
     }<br />
     cout&lt;&lt;endl;<br />
}<br />
int main()<br />
{<br />
    int n;<br />
    int store;<br />
    int tri;<br />
    int j;<br />
    int i;<br />
    cout&lt;&gt;n;<br />
    n=n*2-1;<br />
    int hash[n];<br />
    for(j=0;j&lt;n;j++)<br />
    hash[j]=0;<br />
    hash[n/2]=1;<br />
    int bin[8];<br />
    for(j=0;j&lt;8;j++)<br />
    bin[j]=0;<br />
    cout&lt;&gt;store;<br />
    binRev(store,bin);<br />
    print(hash,n);<br />
    for(j=0;j&lt;n/2-1;j++)<br />
    {<br />
                     store=hash[0];<br />
           for(i=1;i&gt;n;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rule 30 RNG &#171; Programming Praxis</title>
		<link>http://programmingpraxis.com/2009/05/15/cellular-automata/#comment-2950</link>
		<dc:creator><![CDATA[Rule 30 RNG &#171; Programming Praxis]]></dc:creator>
		<pubDate>Fri, 29 Apr 2011 09:04:55 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=573#comment-2950</guid>
		<description><![CDATA[[...] generator that is used in the Standard Prelude. We also looked at cellular automata in a previous exercise. In today&#8217;s exercise we combine random number generators and cellular automata by looking at [...]]]></description>
		<content:encoded><![CDATA[<p>[...] generator that is used in the Standard Prelude. We also looked at cellular automata in a previous exercise. In today&#8217;s exercise we combine random number generators and cellular automata by looking at [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ardnew</title>
		<link>http://programmingpraxis.com/2009/05/15/cellular-automata/#comment-1312</link>
		<dc:creator><![CDATA[ardnew]]></dc:creator>
		<pubDate>Tue, 08 Jun 2010 22:53:44 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=573#comment-1312</guid>
		<description><![CDATA[Anyway, here&#039;s my crappy solution: &lt;a href=&quot;http://pastebin.com/pGyYeYzd&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>Anyway, here&#8217;s my crappy solution: <a href="http://pastebin.com/pGyYeYzd" rel="nofollow">link</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ardnew</title>
		<link>http://programmingpraxis.com/2009/05/15/cellular-automata/#comment-1311</link>
		<dc:creator><![CDATA[ardnew]]></dc:creator>
		<pubDate>Tue, 08 Jun 2010 21:50:51 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=573#comment-1311</guid>
		<description><![CDATA[Nevermind, I was misreading the text :)]]></description>
		<content:encoded><![CDATA[<p>Nevermind, I was misreading the text :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ardnew</title>
		<link>http://programmingpraxis.com/2009/05/15/cellular-automata/#comment-1310</link>
		<dc:creator><![CDATA[ardnew]]></dc:creator>
		<pubDate>Tue, 08 Jun 2010 21:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=573#comment-1310</guid>
		<description><![CDATA[There may be a little bit of confusion with the example rule 158 generations you provide. There are 13 lines listed there, not 12.]]></description>
		<content:encoded><![CDATA[<p>There may be a little bit of confusion with the example rule 158 generations you provide. There are 13 lines listed there, not 12.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Remco Niemeijer</title>
		<link>http://programmingpraxis.com/2009/05/15/cellular-automata/#comment-108</link>
		<dc:creator><![CDATA[Remco Niemeijer]]></dc:creator>
		<pubDate>Fri, 15 May 2009 17:56:26 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=573#comment-108</guid>
		<description><![CDATA[My Haskell solution (see http://bonsaicode.wordpress.com/2009/05/15/programming-praxis-cellular-automata/ for a version with comments):

[sourcecode lang=&#039;css&#039;]
import Data.Bits
import Data.List

successor :: Int -&gt; [Bool] -&gt; Bool
successor r bs = testBit r . sum $
                 zipWith (shiftL . fromEnum) (reverse bs) [0..]

nextRow :: Int -&gt; [Bool] -&gt; [Bool]
nextRow r cs = map (successor r) . take (length cs) . transpose .
               take 3 . iterate (drop 1) $ [head cs] ++ cs ++ [last cs]

displayRow :: [Bool] -&gt; String
displayRow = intersperse &#039; &#039; . map (\b -&gt; if b then &#039;X&#039; else &#039; &#039;)

cells :: Int -&gt; Int -&gt; [String]
cells r h = map displayRow . take (h + 1) . iterate (nextRow r) $
            replicate h False ++ [True] ++ replicate h False

main :: IO ()
main = mapM_ putStrLn $ cells 82 15
[/sourcecode]]]></description>
		<content:encoded><![CDATA[<p>My Haskell solution (see <a href="http://bonsaicode.wordpress.com/2009/05/15/programming-praxis-cellular-automata/" rel="nofollow">http://bonsaicode.wordpress.com/2009/05/15/programming-praxis-cellular-automata/</a> for a version with comments):</p>
<pre class="brush: css;">
import Data.Bits
import Data.List

successor :: Int -&gt; [Bool] -&gt; Bool
successor r bs = testBit r . sum $
                 zipWith (shiftL . fromEnum) (reverse bs) [0..]

nextRow :: Int -&gt; [Bool] -&gt; [Bool]
nextRow r cs = map (successor r) . take (length cs) . transpose .
               take 3 . iterate (drop 1) $ [head cs] ++ cs ++ [last cs]

displayRow :: [Bool] -&gt; String
displayRow = intersperse ' ' . map (\b -&gt; if b then 'X' else ' ')

cells :: Int -&gt; Int -&gt; [String]
cells r h = map displayRow . take (h + 1) . iterate (nextRow r) $
            replicate h False ++ [True] ++ replicate h False

main :: IO ()
main = mapM_ putStrLn $ cells 82 15
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Programming Praxis &#8211; Cellular Automata &#171; Bonsai Code</title>
		<link>http://programmingpraxis.com/2009/05/15/cellular-automata/#comment-107</link>
		<dc:creator><![CDATA[Programming Praxis &#8211; Cellular Automata &#171; Bonsai Code]]></dc:creator>
		<pubDate>Fri, 15 May 2009 17:56:06 +0000</pubDate>
		<guid isPermaLink="false">http://programmingpraxis.wordpress.com/?p=573#comment-107</guid>
		<description><![CDATA[[...] Praxis &#8211; Cellular&#160;Automata By Remco Niemeijer  Today’s Programming Praxis problem is about cellular automata. Let&#8217;s dive [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Praxis &#8211; Cellular&nbsp;Automata By Remco Niemeijer  Today’s Programming Praxis problem is about cellular automata. Let&#8217;s dive [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

