<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by John Whiles on Medium]]></title>
        <description><![CDATA[Stories by John Whiles on Medium]]></description>
        <link>https://medium.com/@johnwhiles?source=rss-1963c55ab90b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*vO1b8rvIS_BIqSiz.</url>
            <title>Stories by John Whiles on Medium</title>
            <link>https://medium.com/@johnwhiles?source=rss-1963c55ab90b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:13:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@johnwhiles/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Conway’s game of Life]]></title>
            <link>https://medium.com/@johnwhiles/conways-game-of-life-d8a16ffe28f?source=rss-1963c55ab90b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8a16ffe28f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[game-of-life]]></category>
            <dc:creator><![CDATA[John Whiles]]></dc:creator>
            <pubDate>Sun, 15 Jan 2017 12:34:36 GMT</pubDate>
            <atom:updated>2017-01-15T12:34:36.574Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week at Founders and Coders, the coding bootcamp where I currently study, a number of developers spent the day working on various implementations of <a href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Conway’s game of life</a>. The exercise was <a href="http://coderetreat.org/">inspired by code retreat</a>. As a group we hoped improve our collective coding skills by pairing with a succession of different people and repeatedly tackling the same problem. Without the pressure of actually having to deliver a working program we were able to focus on writing the best code we could.</p><h3>Data Structures</h3><p>My main takeaway from the day was an improved awareness of how the representation of data can determine the structure of an entire program.</p><p>My first, very naive, attempts tried to represent the state of every single point on a game board of a predetermined size. This lead to needlessly calculating whether cells with no living neighbours would survive, or suddenly spring to life (they never would) and made attempting to calculate what happened at the edge of board painful.</p><p>The major turning point in my understanding of the problem was being told that it was possible to ignore everything except the coordinates of currently living cells. This was all data that was needed to calculate the next game state. I went from wrangling an array of arrays, which pictorially represented the board, to simply having a list of coordinates.</p><pre>[ [ 0, 0, 0, 0, 0 ], <br>  [ 0, 0, 1, 0, 0 ], <br>  [ 0, 1, 1, 1, 0 ], <br>  [ 0, 0, 1, 0, 0 ], <br>  [ 0, 0, 0, 0, 0 ], ]</pre><p>vs</p><pre>[ &#39;1:2&#39;, &#39;2:1&#39;, &#39;2:2&#39;, &#39;2:3&#39;, &#39;3:2&#39; ]</pre><h3>Solutions</h3><p>After spending the day working on the problem, I got home, put some sweet potatoes in the oven, and then wrote what I considered to be a <a href="https://github.com/Jwhiles/game-of-life/blob/af84ff6941b9763a0bc917975d2cc21a9ce6515d/game.js">finished implementation</a>. I was very pleased with this code for about a day, until it was pointed out to me that one of my functions. I snapped back to reality and decided that the code would have to be improved. I also decided that doing so would be a great excuse to learn to use Ramda.</p><p>My current solution <a href="https://github.com/Jwhiles/game-of-life/blob/master/game.js">looks like this</a>. I forced myself to use composition and currying as much as I was able to. I believe that it’s clearer than my previous solution. I’m certain that there is a lot of room for improvement left. If you have any suggestions, please raise an issue!</p><p><em>Originally published at </em><a href="http://www.johnwhiles.com/blog"><em>www.johnwhiles.com/blog</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8a16ffe28f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>