Ad
  • Default User Avatar

    The two subarrays are sorted in ascending order by their number weights if these weights are different; by their indexes in the string if they have the same weights.

    Your code does not always respect that ordering

  • Default User Avatar

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

  • Default User Avatar

    Hi. I got this error - "calling toRandomArray() and then try to get a given permutation of values
    After 100 attempts, has not obtained the desired permutation. Check the randomness of your solution."
    All tests pass except for this one. Could you tell me what is the test case fail?

  • Default User Avatar

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

  • Default User Avatar

    "Ethan,Sophia,Elijah,Addison,Alexander,Matthew,Abigail,Logan,Mason,Isabella,Chloe,Jacob,William,Grace,Benjamin,Michael,Lily,Aiden,Avery,James,Mia,Noah,Ava",
    [ 3, 4, 4, 4, 4, 1, 4, 1, 6, 3, 5, 3, 3, 5, 1, 3, 1, 2, 4, 4, 1, 3, 5 ], 2), "Alexander")
    case gives mecorrect result in ide and gives error it test.. JS

    function rank(st, we, n) {
    if (st.length === 0) return "No participants";
    else if (n > st.split(',').length) return "Not enough participants";
    

    let albt = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    let vinNum = st.toLowerCase().split(',').map( (el,i) => (el.split('').
    reduce( (acc,cur) => acc + +albt.indexOf(cur) + 1,0) + el.length) * we[i]);
    let lst = st.split(',').reduce( (acc,cur,i) => {
    return acc.push([cur,vinNum[i]]),acc;
    },[]).sort(([a,b],[c,d] ) => d - b ).sort(([a,b], [c,d]) => {
    return b === d && a.length === c.length ? -1 : 0;
    });
    return lst[n-1][0];
    }

    console.log(rank("COLIN,AMANDBA,AMANDAB,CAROL,PauL,JOSEPH",
    [1, 4, 4, 5, 2, 1], 4), "PauL");
    console.log(rank("William,Willaim,Olivia,Olivai,Lily,Lyli",
    [ 1, 1, 1, 1, 1, 1 ], 1), "Willaim");
    console.log(rank("Elijah,Chloe,Elizabeth,Matthew,Natalie,Jayden",
    [ 1, 3, 5, 5, 3, 6 ], 2), "Matthew");
    console.log(rank("Ethan,Sophia,Elijah,Addison,Alexander,Matthew,Abigail,Logan,Mason,Isabella,Chloe,Jacob,William,Grace,Benjamin,Michael,Lily,Aiden,Avery,James,Mia,Noah,Ava",
    [ 3, 4, 4, 4, 4, 1, 4, 1, 6, 3, 5, 3, 3, 5, 1, 3, 1, 2, 4, 4, 1, 3, 5 ], 2), "Alexander");

  • Custom User Avatar

    Hmmm. This appears to be a quirk of of the assert.closeTo from the test framework
    https://www.chaijs.com/api/assert/#method_closeto

    You can see for yourself by hardwiring different values near the expected boundary.

    function howBiggaMaPizza(blob, crust) {
      return 5.7719999999; // Result: expected 5.7719999999 to be close to 5.773 +/- 0.001
      return 5.772;        // Result: PASS
      return 5.7739999999; // Result: PASS
      return 5.774;        // Result: expected 5.774 to be close to 5.773 +/- 0.001
    }
    

    So your solution needs to be a tiny bit closer to pass.

  • Default User Avatar
  • Custom User Avatar

    Which language?

  • Default User Avatar

    With blob 10 and 'thick' crust ma famous pizza radius is 5.773
    expected 5.774 to be close to 5.773 +/- 0.001

    test fail, but should pass.