Ad
  • Custom User Avatar

    Because sort isn't stable in all of them.

  • Default User Avatar

    Maybe you have the answer...

    First, it's a question not an issue of the kata (notice that 7505 people passed the JS kata; if there were problems somebody else would already said!). Second, the answer is: your code is wrong:-) I strongly doubt that it gives correct answers for all tests on another platform...

  • Custom User Avatar

    Yes, printing the input, in javascript, use console.log()

  • Custom User Avatar
  • Default User Avatar

    Rather than post that much code and expect someone to explain why it doesn't work, can you give more info?

    Does it work at all, if not what errors do you see in the console?

    If it works but only for some cases, which cases does it fail on? Can you provide a test case which your code does not pass?

    Giving a bit more info will likely get you a more helpful response.

  • Custom User Avatar

    I found your mistake! Something goes wrong when you split in groups of three. I don't know what's exactly wrong because I'm not that good with regex but the mistake must be somewhere here:

    let regex = /(111|000)/g
    while (match = regex.exec(num)) {
        matches.push(match[0])
    }
    

    You get following triples:

    [ '111',
      '111',
      '000',
      '111',
      '000',
      '000',
      '000',
      '111',
      '111',
      '000',
      '000',
      '111',
      '111',
      '000',
      '111',
      '111',
      '111',
      '000',
      '111' ]
    

    But the correct ones would be:

    100
    111
    111
    000
    111
    000
    000
    010
    000
    111
    111
    000
    000
    111
    001
    111
    000
    111
    110
    111
    111
    000
    010
    111
    

    You also have to correct mistakes, which I think doesn't work with your code, meaning:
    010 -> 000
    110 -> 111
    etc..

    Just ask if you have more question I hope I could help you. Try to implement it strict to the steps in the description and I'm sure you'll make it. :))

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    please post your code with spoiler flag, so I can help you :)