Ad
  • Custom User Avatar

    Python fork here:
    https://www.codewars.com/kumite/6a279479b9242e8ca2d47e13?sel=6a279479b9242e8ca2d47e13

    Which addresses the issue above. Notes:

    1. Replaced author solution with one which parses non-regular (i.e. arbitrarily nested) chemical formulae
    2. Added a non-regular example to fixed tests
    3. Replaced random test generator with a tree-based generator which generates properly random formulae and their atom counts (obviates the need for a reference solution)
  • Custom User Avatar
    • kata ranks cannot be changed
    • it is not a regular language since parentheses can be nested
  • Custom User Avatar

    kata ranks cannot be changed

  • Custom User Avatar

    Python random tests contain nested brackets but do not contain multipliers on them, whereas fixed tests contain multipliers on brackets but no truly nested brackets (each layer of brackets is a unique pair of symbols). This means that all the flat regex-based parsers in the Python solutions - of which there are many, including my first attempt - are failing to actually parse the random tests.

    Give most of the top solutions for python this test case and they will not succeed:

    ("(Al(H2O)6)2(SO4)3(H2O)5", {'H': 34, 'O': 29, 'S': 3, 'Al': 2}, "Should parse alunogen: (Al(H2O)6)2(SO4)3(H2O)5")
    

    More proof: a parser which just ignores the brackets entirely for the random tests
    https://www.codewars.com/kata/reviews/55770da1dcdc57f27f00004b/groups/6a2638d8e4d51c69b2f53041

    If the intention of the kata is to test formulae as a regular language, as I expect from the description/fixed tests, then random tests should not be generating brackets nested within brackets of the same type (at 5-kyu at least).

    If the intention of the kata is to test formulae as a non-regular language, then that should be reflected in the fixed tests with nested brackets. This will invalidate many solutions.

    Random tests should have multipliers on brackets regardless.

  • Custom User Avatar

    Haskell fork adding random tests.

  • Custom User Avatar
        $this->assertFalse(validate_battlefield([
            [1, 1, 0, 0, 0, 1, 1, 0, 0, 0],
            [1, 0, 0, 0, 0, 0, 0, 0, 1, 0],
            [1, 0, 0, 0, 1, 1, 1, 0, 1, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
            [0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
            [0, 1, 0, 1, 0, 0, 0, 0, 0, 0],
            [0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        ]));
        
        public function testAdditionalShipWithLengthFiveIsInvalid(): void
    {
        $field = [
            [1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [1, 1, 1, 1, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [1, 1, 1, 0, 0, 0, 1, 1, 1, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [1, 1, 0, 0, 0, 1, 1, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            [1, 0, 1, 0, 1, 0, 1, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        ];
    
        $this->assertFalse(validate_battlefield($field));
    }
    

    Please add this test.

  • Custom User Avatar

    Why are you moving __ in your nickname?

  • Custom User Avatar

    there is green between them

  • Custom User Avatar

    Too hard to be yellow, too easy to be blue.

  • Custom User Avatar

    I replaced the author's solution with my own and uncommented those tests. the timeouts / OOM errors should no longer happen.

  • Custom User Avatar

    My first 3 kyu kata! Thanks alot :D

  • Custom User Avatar

    Updated the fork

    • Improved random test generation to avoid having to re-parse the molecule
    • Improved tests to provide more useful failure messages
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    this is one of katas that you should have hints about it, it they don't help you, get the solution and absorb it.

  • Custom User Avatar
  • Loading more items...