Ad
  • Default User Avatar

    Yes, that's strange, as I get the expected error with the same code. This definitely does seem to be an issue. You can report the bug here: https://github.com/Codewars/codewars.com/issues

    I have no idea what would cause that.

  • Default User Avatar

    I copied and pasted the nonsense code that I wrote above, but I changed return $a; to return [];, and I got the expected error: Failed asserting that two arrays are equal.

    Whatever you're doing, the tests can't find your get_generation function. It's unlikely that this is something that just affects you, as all the code is run server-side. There must be something wrong with your code. You could post it here (marked as a spoiler if it contains code pertaining to this kata).

  • Default User Avatar

    You can use classes. Just have a global function called get_generation() and instantiate your classes in it, and run the code that way.

    So it would look like:

    class Alpha{
    
      private $cells;
    
      function __construct($cells){
        $this->cells = $cells;
        //blah blah blah
      }
      function doStuff(){
        //blah blah blah
      }
    }
    class Beta{
      function test(){
        //blah blah blah
      }
    }
    
    function get_generation(array $cells, int $generations): array {
      $a = new Alpha($cells);
      $b = new Beta();
      $a->doStuff();
      //and so on...
      return $a;
    }
    

    Something like that. The actual tests on the kata are all testing whether the get_generation function returns the correct result, so if you don't have a get_generation function to test, it won't work.