Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
funny cheat :-)
This is some cheat to pull out all of the data to guess the formula
Cheating!
This solution won't work if field is filled with "5" (for example).
This solution won't work if entire field is filled with "5" (for instance).
There is an issue: initial template cannot be compiled as size_t needs to be defined (so at least <stdio.h> needs to be included)
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I spent a bunch of hours to determine the reason of problem.
The cells parameter for should_work_for_a_single_glider_over_all_4_repeating_generations points into not allocated memory, just try to run the code I suggested - it dumps cells parameters for all of the cases and only for this one it crashes. I tried a lot of tests. For my case there were situations when calloc() returned value equal to cells which is clear impossible. Or maybe the test instance has broken static memory and needs to be restarted.
p.s. if you insist that I should return the result of calloc() (to avoid double free) - ok, I changed my solution to do it, but hey, the htmlize() should not return this on cells input:
p.p.s. my java version of this code works ok, other tests work ok
The "C" test is broken, it crashes with SIGSEGV. Simple proof of concept:
int **get_generation (int **cells, int generations, int *rowptr, int *colptr)
{
char *universe = htmlize(cells, *rowptr, *colptr);
printf("%s\n", universe);
free(universe);
return cells;
}
It crashes for one of the tests.