Ad
  • Custom User Avatar

    I'm such an idiot =\ sorry and thank you. Don't know why I convinced myself that it should be sorted...

  • Default User Avatar

    Hi, let's isolate the issue. The problem is not in your editor or CW, the assert.deepEquals method or the input length. Your code solves a different problem :)

    Look at the following case:

    var input = "233312"
    yourSolution(input) === [ [ '3', 3 ], [ '2', 2 ], [ '1', 1 ] ]
    expectedResult      === [ [ '2', 2 ], [ '3', 3 ], [ '1', 1 ] ]
    

    Hint: The description says: "return it as a list of tuples in order of appearance."

    Regards,

    suic

  • Custom User Avatar

    I'd be happy to attach a screenshot with the result. It doesn't but I can compare what it's expected with the output I receive in my editor - and they are the same.
    All the directions I can get from test error messages show that the output is not sorted: all characters just follow the same sequence as they were in the input data. Which is strange, because I definitely return sorted one, and it is sorted testing in your own editor.
    I know, it all seems too presumptuously for a 7 kyu memeber, but I'm just trying to find out what's wrong and I can't

  • Default User Avatar

    How does your editor know the correct answer?

  • Custom User Avatar

    Yep, passing this input "1175192891585310852643994879501287928505966103527635411078058871457138431587047" for example. we expected [ [ '1', 12 ],
    [ '5', 12 ], [ '8', 11 ],
    [ '7', 9 ], [ '0', 7 ],
    [ '9', 7 ], [ '3', 6 ],
    [ '4', 6 ], [ '2', 5 ],
    [ '6', 4 ] ] to deeply equal (and got this) [ [ '1', 12 ],
    [ '7', 9 ], [ '5', 12 ],
    [ '9', 7 ], [ '2', 5 ],
    [ '8', 11 ], [ '3', 6 ],
    [ '0', 7 ], [ '6', 4 ],
    [ '4', 6 ] ]
    But if I run the solution in my editor - I get the correct (sorted in descending order) output array. I ran out of ideas what could be wrong :(

  • Default User Avatar

    if you carefully examine the random test error messages you can figure out how to correct your output based on the directions

  • Custom User Avatar

    Hello! I'm afraid I need help, but I don't want to refer to the solution. Could anyone please point what I'm doing wrong here:

    const orderedCount = (text) => {
    if (!text || text == '') {
    return [];
    }
    let arr = text.split('');
    let obj = {};
    let resultArr = [];
    for (let i = 0; i < arr.length; i++) {
    let counter = 0;
    arr.forEach(el => {
    if (arr[i] == el) {
    counter++;
    }
    });
    obj[arr[i]] = counter;
    }
    for (p in obj) {
    resultArr.push([p, obj[p]]);
    }
    resultArr = resultArr.sort((a,b)=>{return b[1]-a[1]});
    return resultArr;
    }

    Sample tests were passed successfully, however I constantly receive the error 'to deeply equal' when it comes to long numbers passed as an argument - in such cases the output array isn't sorted for some reason. '212' test is ok. Ofc first I checked it myself with a number from a failed test - got the expected result. Thanks in advance, guys!