CREATE VIEW live_neighbours AS
SELECT simulation, generation, x+dx as xx, y+dy as yy, count(*) as cnt
FROM life
JOIN neighbour_coordinates
GROUP BY simulation, generation, xx, yy;

Isn't SQL great? We already have neighbour counts for every cell in the simulation with one or more neighbours.

LEFT OUTER JOIN of DOOM

Now it's simple step - for cells which are alive we calculate them as alive if they have 2 or 3 neighbours in previously calculated view - for cells which are dead if they have exactly 3 neighbours. That's a simple JOIN on x and y... Oh wait, we're not joining data, we're joining existence or nonexistence of cell in life table, so we need a special kind of JOIN:

What's next?

Next step would obviously be ASCII-Artifying output instead of just dumping a list of X/Y coordinates as a table - and possibly similar ASCII-Art reader. Unfortunately 45 minute limit on the round prevented that from happening.

I'd like to thank my coding partner for cooperation in writing this. For understandable reasons I'm not going to do any doxxing.

My software

Creative Commons

Unless otherwise expressly stated, all original material of whatever nature created by Tomasz Węgrzanowski and included in this blog, is licensed under a Creative Commons License. It is also licensed under GFDL (for Wikipedia compatibility).