Ad
  • Custom User Avatar

    I have rebuilt Random test cases as it should be:

    describe("Random Cases", function(){
    it("Challenging Cases", function(){
    var arr1, arr2, length, i, elem, result, res;
    for (var h = 0; h <= 100; h++) {
    arr1 = [];
    length = randint(10, 5000);
    for (i = 0; i <= length; i++) {
    elem = randint(0, 1500);
    if (arr1.indexOf(elem) < 0) arr1.push(elem);
    }
    arr2 = [];
    length = randint(10, 5000);
    for (i = 0; i <= length; i++) {
    elem = randint(0, 1500);
    if (arr2.indexOf(elem) < 0) arr2.push(elem);
    }
    result = process2ArraysRandomCases(arr1, arr2);
    res = process2Arrays(arr1, arr2);
    Test.assertSimilar(res, result);
    }
    });
    });

  • Custom User Avatar

    "We need a function that receives two arrays arr1 and arr2, each of them, with elements that OCCUR ONLY ONCE."

    But in test cases (javascript version) elements occur NOT only once.
    It was neccessary to prefilter arr1 to solve this kata:

    arr1 = arr1.reduce((arr, el) => arr.indexOf(el) > -1 ? arr : (arr.push(el), arr), arr1.slice(0,0));

    Only after that filtering I have passed all the test cases.

  • Custom User Avatar

    "I'm looking so cool today"

    Expected: 5, instead got: 6

    1)I
    2)m (short form from "am")
    3)looking
    4)so
    5)cool
    6)today

  • Custom User Avatar

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

  • Custom User Avatar

    ...
    return [arr1.length, arr2.length];

    Expected: '[0, 1494, 1494, 0]', instead got: '[3999, 0]'

    arr1.length === 3999,
    arr2.length === 0,

    So how did you get [0, 1494, 1494, 0] ?

    I think there is a mistake in Random Cases (javascript version).

  • Custom User Avatar

    Javascript:
    6 static cases passed successfully,
    but all 101 challenging cases failed.

    For example:
    Expected: '[0, 1480, 1480, 0]', instead got: '[0, 4333, 4333, 0]'

    But actually arr1.length is 4333, arr2.length is 0, so we should get:
    (1) ---> 0 # because the elements present in both arryas are: none
    (2) ---> 4333 # beacause elements present in only one array are: arr1.length
    (3) ---> 4333 # elements remaning of arr1 are: 1, 3, 5, 7, 9: arr1.length
    (4) ---> 0 # elements remaning of arr2 are: arr2.length === 0

    So what is wrong with JS Random cases?