Ad
  • Default User Avatar

    Unfortunetly thats true, instruction is contradictory in one place

    "negative-base number being one digit longer than its positive-base equivalent"
    ...
    "For example, the representation for 6 is '11010' and -6 is '1110'."

    Negativ is shorter here, so people are disoriented. I am.

  • Default User Avatar

    Same here, I don't get the instructions. Sry

  • Custom User Avatar

    Instructions aren't clear, probably because neither example looks like it's using one's or two's compliment. How is +6 equal to '11010'? Shouldn't it be '110' or '0110'?
    Though, -6 being equal to'1110' makes sense if you're using one's compliment.

    What does 1 and -1 look like? What does 2 and -2 look like? What does 3 and -3 look like?

    Nevermind...negative base number systems. Missed that info.

  • Custom User Avatar

    Well done ;-)

  • Custom User Avatar

    Solution was to change !value to typeof value === 'undefined'.

    When an element was 0, it was exiting the fn prematurely.

  • Custom User Avatar

    myjinxin2015, How are you formatting code in the comments?

  • Custom User Avatar

    Thanks for all the help! Your question about !value is for the case there's only one element in the original array.
    Since, as you've correctly pointed out, sorted.shift() changes the array length, value will be undefined so this allows the function to exit with the correct value.

  • Custom User Avatar

    I should go to bed, so many suggestions for the time being.

  • Custom User Avatar

    another wrong(maybe) is there: !value || last !== value

    I don't know !value mean, but I know if value==0 what will happen ;-)

  • Custom User Avatar

    another wrong is there:var value = sorted.shift();

    if you used shift(), your array length will changed, and you use for loop, i<=len should got some undefined value

  • Custom User Avatar

    another wrong is there: for(i=0; i<=len; i++){

    i<=len should be i<len

    sorted[len] ====== undefined

  • Custom User Avatar

    I think it because you modified the original array.

    the first line maybe write like this:var sorted=A.slice().sort(doSort)

    I can't sunmit your code now, CW running slowly...

  • Custom User Avatar

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

  • Custom User Avatar

    paste your code here is a good idea ;-)

    Don't forget mark as having spoiler content

  • Custom User Avatar

    It's odd, I keep getting different results for the submit tests. Sometimes I get 1 fail, sometimes 9 fails, sometimes 4 fails. But the tests I've written are consistent. And since there's no output for the tests other than 'failed' I cannot figure out WHY those tests fail.

    Are you sure the tests that are being generated are correct?