Life is Simple trouble (task 56)

Back to General discussions forum

connor_macD     2014-10-15 21:35:22

I've been attempting to solve the Life is Simple problem, and I believe the output the website thinks is correct is not. I have verified the output of my program by hand and with a simulator I found online. I am outputting the number of alive cells for each step after the initial board, keeping alive cells surrounded by 2 or 3 alive cells and killing all others, and making empty cells alive if surrounded by 3 alive cells, as specified.

Also on a side note, the example and my code give the same results.

Rodion (admin)     2014-10-16 03:32:34
User avatar

Hi! Thanks for writing about your suspicions!

I'll have a look at your code and its results and return here soon!

UPD It looks your solution (pretty correct an nice in most regards) could be affected by edge-effect of the small board. There is a Note at the end of problem statement:

if you will implement the game using a kind of 2D array, make sure it is large enough and the initial configuration is placed far from edges, so that it will not reach them in 5 moves - otherwise your results could be spoiled.

I.e. though initial position is given as 5*7 rectangle, we need to keep in mind that life is working on the endless field of which this rectangle is just a fragment.

You may try the following example of initial position - small glider close to the corner:

-------
-XXX---
-X-----
--X----
-------

It is slowly travelling diagonally (in top-left direction) containing 5 cells on each step. Your code gives almost correct result:

5 5 5 5 4

(the last value should also be 5 instead)

So I guess it only needs some small fix to avoid hitting edges. Hope this may help!

connor_macD     2014-10-16 20:49:51

Ah so the initialization just limits the initial configuration to the 5x7 rectangle, but this rectangle is in an infinitely large plane. Thank you for clarifying and pointing out the note to me. I'll try to read better next time :)

kolesnikovala394     2022-03-11 13:23:54

Hello, everyone!

i dont understand the task Life is Simple

The origin grid is

-XXXX-X
--X--XX
-X---X-
X-XX-X-
XX---X-

The grid after the first step is

-XXXX-X
------X
-X-X-X-
X-X--XX
XXX-X--

Is it right or not?

Thanks for helping)

Rodion (admin)     2022-03-11 13:30:27
User avatar

Hi Friend!

you seemingly understand rules right, however there was somewhere note that you shouldn't truncate on borders.

e.g. you want to grow grid if the next generation is too large

kolesnikovala394     2022-03-11 13:55:36

Thanks for helping!

Done!

Please login and solve 5 problems to be able to post at forum