November 23, 2014

Global Day of Coderetreat 2014

This year I participated in the Global Day of Coderetreat, and I can't wait for next year!

We spent the day solving the problem laid out in Conway's Game of Life. On the surface, this is a fairly easy game that can be implemented in any programming language. This is the reason it is used for Coderetreats. The interesting part isn't the game, but the constraints put on solving the problem.

Everyone is divided into groups and given the rules for Conway's Game of Life. To begin the day, you simple start discussing the problem and maybe laying out some code. After 30 minutes, the first session is over - you delete any code that was written and shuffle partners. You quickly learn that the code has very little to do with this exercise as this process is repeated several times throughout the day.

One session required us to solve this problem without any methods that had more than 3 lines. We were also introduced to other elements of Clean Code, like the Four Simple Design Rules. Another session imposed the restriction that we couldn't use any loops. One of the most interesting sessions required us to work in silence for the half hour. That's right, we could only communicate with our partners through code. By the end of the day we had learned a lot about improving our code.

I came into this coderetreat thinking that I wouldn't be able to contribute much to the discussion. I figured that all the other participants would be veteran programmers and I wouldn't understand much of what was happening, but it would be a great learning experience. It turns out I was right about the learning experience, but I also added a lot to the groups I worked with. At the end of the coderetreat, one of my partners during the day commended me for thinking outside the box and creating an algorithm that allowed us to solve this problem without conditionals or loops in our code.

At the end of the day, my work was used in the code that allowed two teams to present working implementations of Conway's Game of Life. Out of the five teams that were there that day, only the two that used my algorithm were able to code a working game within in the time we had. One of those solutions is presented here (this solution used loops and conditionals because we deleted the previous code). In addition to removing the need for loops and conditionals, my algorithm made it possible to code the solution in less time.

I figured that we didn't need loops if we knew how many living neighbors each cell had. This lead me to suggest we create a hash table with the living neighbor tally. Each time a cell came to life it would add one to the tally for each of its neighbors. Since this only required changing the values for eight keys in the hash, it was possible to do this without any loops. Then we could also avoid using conditionals with the select method that would pick only those keys associated with a specific value. Essentially, according to Conway's rules, any cell with exactly three living neighbors would come to life and any living cell with exactly two neighbors would survive into the next round of the game.

My biggest contribution to the day was the use of this hash table, and it was the key difference between the solutions that were implemented within the allotted time and those that were unable to create a working solution. Although I was much slower with the code than my team members, I was still able to contribute valuable ideas to help solve this problem efficiently. I look forward to the Global Day of Coderetreat next year and plan to contribute my programming skill in addition to interesting algorithms.

Have a question? Just contact me.

Be in Touch

+1 (828) 479-5663
Copyright © FrankCJones.com
envelope linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
WordPress management provided by OptSus.com