Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • It fails this test case: $this->assertEquals(true, XO("xxOo"));

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

  • I was able to find some information on this after asking around for keywords. I think the state-of-the-art method is a O(n sqrt(log n)) one for an integer array, described in (link in spoiler comment below). Subsection 1.3 (essentially) mentions this problem as the first example application, IIUC. I'm trying to study it at the moment but I'm not familiar with advanced data structures so it's probably not going to be easy.

    If you want to use the 'easier' approaches (one that would work here fine) (not explicitly stating for fear of spoiling), then it's obviously Omega(n log n) because doing this on the array and its reverse gives you sorting.

  • So I was solving this kata in javascript and trying my 'for loops' with syntax like "for (i in str1)" and was getting runtime error above 12000ms. I then changed my for loops to the classical "for (i = 0; i < str1.length; i++)" and got my total run time to 6387ms. Amazing!! Didn't know there was that much of a difference!

  • this test is ez

  • Maybe there is time out? even if you pass all tests, if there is time out it will not accept

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

  • I can not tell. All the tests i run, are working. But anyways, this kata is not my favorite. Thanks for helping and hava a nice sunday!

  • Just solved the kata in Java and encountered no problems. If your solution does not pass, it's probably wrong.

    If you do not see any useful error message, it can either time out or crash in some other way. If you see the error message but you do not know what it menas, then paste it here or show us your code so we could drop some hints.

    Kata and its Java version seems to be OK.

  • If it worked, it would pass. 4000+ people solved it in java somehow.

    I don't know what you mean by "The error message says nothing": the result is either true or false, so if you print what you return and there's an error, it's probably expecting the opposite. However, the error MUST be saying something...

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

  • I don't get why this is a 5 kyu question, i find it pretty simple and easy to do. At least from my perspective doing the question in java.

  • The problem was with my code indeed! I simplified the solution and it passed normally on Codewars now.

    I have my local repo setup with TS, mocha and ts-node and I execute the test task in package.json to verify that all tests pass.

      ...
      "test": "mocha \"test/**/*.{ts,js}\" --recursive -r \"ts-node/register\" -r \"tsconfig-paths/register\"",
      ...
    

    It's with this setup that my erroneous code passed and I want to investigate further why that was the case.
    When I executed via a classic node cli terminal locally, it threw the same memory error as Codewars did!

    I will post here my findings when I find out what magic did the TS compiler and my code passed in the first iteration.

  • You might be running into an infinite loop or something... The error says you tried to allocate too much memory, possibly for a very big array. I'd bet that's from your code, and not the tests. Did you try logging stuff to console to see if that's the case?

  • Loading more items...