Beta

Loop Through Conway's Game of Life

Description
Loading description...
Algorithms
Cellular Automata
  • Please sign in or sign up to leave a comment.
  • Voile Avatar

    This kata is merely a trivial combination of two unrelated tasks (evaluating GoL state and finding tail/loop size of a linked chain) which individually already have katas of, so this is a duplicate.

  • Voile Avatar

    This kata is not solvable in general; a glider, for example, will not loop at all.

  • dolamroth Avatar

    Could anyone make Python or JS translation, please?

  • Blind4Basics Avatar

    no random tests (or at least, enough randomized ones?)

  • Insti Avatar

    It would be good to include the life/death rules so that this kata could be completed without the dependency on wikipedia.

  • Dr Phil Avatar

    Here are some things that I think would make this Kata better: Have test cases that are of non-square grids. Give an estimate in the description for how large boards and how long tails and loops the code should be able to do. And although I think it's minor, it's nice to have one randomized test so that it's impossible to save the answers to complete the kata.

    Good work!

  • Dr Phil Avatar

    This Kata seems really interesting. A small question though, are the edges joined together? Say a glider went out the right side, should it come back on the left?

    • bellmyer Avatar

      Yeah, I might not have been clear enough in my description, but that's what I meant by "pacman-style" :) I'll see if I can clarify the wording.

    • Dr Phil Avatar

      Pacman style? But it should wrap around then? I'll give it a try! :)

    • bellmyer Avatar

      Sorry, I must have removed the "pacman-style" comment I originally had :) I updated the description, and even added an example that I hope helps. Let me know how it goes!

    • Dr Phil Avatar

      Are the given test case in "Your Test Cases" really correct then? Or have you changed it since I started? I don't think

      [[1, 0, 1], [0, 0, 1], [1, 0, 0]]
      should have a tail at all? Since all cells will be in reach of eachother...

    • Dr Phil Avatar

      I could really need some help. On the first 5x5 board I just can't see how it can be a tail=2, loop=2 solution. I get a tail=16, loop=1 answer. I've tried checking my boards for errors, but it's kind of tough to hand check 17 5x5 boards. Could you please post the four boards of the first test so I can compare my boards with it, so I can track down my error? It's the one starting with

      10011
      01111
      00001
      10100
      10100
      . It would be much appreciated!
    • bellmyer Avatar

      Indeed you are right! When building the "next grid", I was initializing my 2-dimensional array like this:

      next_grid = [[]] * 3
      

      Which gives you:

      [[],[],[]]
      

      That looks correct for a 3x3 grid, but what you can't see is that all three sub-arrays are the same object. Therefore, changing one changed all, and all three rows ended up being identical. Woops! I'm going to fix the test cases now.

    • bellmyer Avatar

      Very sorry for the mixup. I've corrected everything - my solution code, the test suite, and the example test suite. Thank you very much for finding this glitch!

    • Dr Phil Avatar

      Okay, so I had the code right after all. :P It was a fun exercise, I hope more people will try it. :)