Ad
  • Custom User Avatar

    I have a problem with randomTests, always one of the tests fails in the same way after 6-10 tests.

    Env: PHP 8.0
    Json of array elements $piecesPositionList

    ["E_Yellow","A_Red","C_Yellow","C_Red","G_Yellow","B_Red","D_Yellow","B_Red","A_Yellow","E_Red","A_Yellow","G_Red","G_Yellow","D_Red"]"
    

    My result: Win:Yellow

    Tests result:

    Failed asserting that two strings are identical.
    Expected: 'Red'
    Actual  : 'Yellow'
    

    The problems I see:

    1. the tests are written in such a way that once in a while under the right assumptions of the algorithm this problem occurs. This is impossible to debug
    2. my algorithm is too inefficient and causes phpunit error (this is unlikely)

    Any possible suggestion of a solution is welcome.

  • Custom User Avatar
  • Custom User Avatar

    it is still poorly written despite the number of people who passed. It just means they read other comments or did more research to understand this problem further. The problem here lies in the interpretation itself rather than in the actual problem solving.

  • Custom User Avatar

    Before posting an issue you should look at the top of the page to see how many people passed the kata in your language (995 with PHP). If this number is big enough (and it is!) chances are your code is wrong or you didn't understand the description.
    A good source of info when you fail is to read comments of other people.
    Since you are new at CW you should read https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution.

  • Custom User Avatar

    I have a problem with this Kata in PHP 7.0.

    I failed test,but I think I should have passed.

    I got an error:

    Failed asserting that two strings are equal.
    Expected: 'wlwsasphmxxowiaxujylentrklctozmymu'
    Actual  : 'owiaxujylentrklctozmymuwlwsasphmxx'
    

    But if I dump $strarr and $k

    $strarr =
    array(3) {
      [0]=>
      string(11) "wlwsasphmxx"
      [1]=>
      string(23) "owiaxujylentrklctozmymu"
      [2]=>
      string(10) "wpgozvxxiu"
    }
    
    $k = int(2)
    

    As you can see, the first value shoud be owiaxujylentrklctozmymu and second wlwsasphmxx, but test makes us provide wlwsasphmxx first and owiaxujylentrklctozmymu second.

    Test name: ConsecutiveTestCases -> testBasics