Ad
  • Custom User Avatar
  • Custom User Avatar
  • Default User Avatar

    Incorrect kata.
    Since in the description it says "We need a function that receives two arrays arr1 and arr2, each of them, with elements that occur only once".
    OCCUR ONLY ONCE!
    But in the random tests there are a lot of repetitions. So be careful - you have to filter array first to leave just unique valu@es.
    @raulbc777, you should change either description or tests.

  • Default User Avatar

    Definitely something wring with the random tests (I failed 20 of them after passing all of the basic tests):

    Small Arrays
    arr1: [34, 38, 7, 6, 4, 46, 17, 36, 33, 45, 1, 47, 13, 14, 11, 32, 20, 9, 49, 18, 21, 35, 19, 40]
    arr2: [33, 2, 30, 46, 15, 5, 20, 11, 0, 24, 50, 6, 37, 16, 13, 29, 44, 32, 21, 1, 12, 35]
    ✘ Expected: [0, 26, 14, 12], instead got: [10, 26, 14, 12]

    The intersection of the two arrays is [6, 46, 33, 1, 13, 11, 32, 20, 21, 35] for a length of 10.

    Confirmed with minitest on my local machine:

    def test_random_example
    arr1 = [34, 38, 7, 6, 4, 46, 17, 36, 33, 45, 1, 47, 13, 14, 11, 32, 20, 9, 49, 18, 21, 35, 19, 40]
    arr2 = [33, 2, 30, 46, 15, 5, 20, 11, 0, 24, 50, 6, 37, 16, 13, 29, 44, 32, 21, 1, 12, 35]
    assert_equal(process_2arrays(arr1, arr2), [10, 26, 14, 12])
    end

    Running:

    .

    Finished in 0.001227s, 814.9959 runs/s, 814.9959 assertions/s.

    1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

  • Custom User Avatar

    (see previous comments)

    redid the KATA and removed the duplicate entries and the code worked.

  • Custom User Avatar

    For the designer of this KATA, I hope this information is helpful to you:

    I did this KATA using JavaScript and experienced odd results......so:

          I modified it to test for empty arrays (for either arr1 and/or arr2) so that the result 
          could be populated with a minimum of calculations.
    
          I also used two for loops that used indexOf to see if an element of one array exists in the other.
          I did this in order to avoid the complication of sorting and/or checking for duplicate elements.
    

    What should have resulted is the code should have worked regardless of empty arrays and/or duplicate data. What actually resulted was I still received a boatload of errors on the test results.

    I then console logged the array values within the test results to see what was actually being conveyed
    as arguments to arr1 & arr2 and tested my code fully outside of the codewars environment
    and it executed perfectly.

    I am fairly certain that there is an issue with your test cases.

  • Custom User Avatar

    This is the first time I created my own test cases. Thought I followed the directions properly and created this line:

    Test.assertEquals(pascalsTriangle(5), [ 1, 1, 1, 1, 2, 1, 1, 3, 3, 1, 1, 4, 6, 4, 1 ]); The first argument being the function with its argument stated, and the 2nd argument being the answer expected. ...not sure what I did wrong.

    Secondly, I hit submit to have the creaters test cases run and passed all the tests. ...Also did not get a final submit button to show.

    Help would be greatly appreciated.