Ad
  • Custom User Avatar

    The description warns you:

    Also, make sure your method doesn't return until all three threads have completed. Otherwise the tests may not work even if your solution is correct.

    that's the main issue. when you fix that, that test will work (but another is still failing, there are some out-of-order calls). In any case, that's a problem with your code , not a kata issue

    it works locally

    is never a good argument, especially not with threading and concurrency ;-)

  • Custom User Avatar

    Hi, I had the same problem. Locally my code is running properly, println() prints numbers from count() method in correct order, but tests say that I return an empty array.

  • Custom User Avatar

    The testTrickyQueues test data looks like this

          new int[0], // G
          new int[]{0,0,0,6}, // 1
          new int[0], // 2
          new int[0], // 3
          new int[0], // 4
          new int[]{6,6,0,0,0,6}, // 5
          new int[0], // 6
    

    And expecting new int[]{0,1,5,6,5,1,0,1,0}

    Let's work thru the first few floors...

    • Lift starts at FLOOR 0 going UP
    • Lift going up is called by someone at FLOOR 1 who wants to go to floor 6. They get in. Lift contains {6}
    • Lift going up is called by people at FLOOR 5 wanting to go to floor 6. Three people get in. Lift contains {6,6,6,6}. Still going up.
    • Lift gets to FLOOR 6. Everybody out. This is top so now lift will go DOWN.
    • Lift going down is called by people at FLOOR 5 wanting to go to ground. Those three get in. Lift contains {0,0,0} and is going DOWN
      *...

    You can see that so far the lift has stopped at FLOORS 0,1,5,6,5 .... which is the first part of the required Kata answer.

    ~

    I leave the rest as exercise for the reader ;-)

    Cheers!

  • Custom User Avatar

    @Álex Vega Don't forget the spoiler flag.

  • Custom User Avatar

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

  • Custom User Avatar

    The given property (P) is correct. If there were an error I hope somebody would have seen it before you:-) Did you give it a try?

  • Custom User Avatar

    java.

    But I just checked and the ref solution returns false for this input.

    @dawidszewczyk: that's not the input that caused your solution to fail. Check that you're logging appropriately in your code (like, do you have an early return before you might log?)

    Invalid issue, closing. But if you actually find one, plz continue the discussion (with other inputs, but double check that's the correct one and that you didn't mutate it before you print it)

    cheers

  • Custom User Avatar
  • Custom User Avatar

    'Means your structure must be wrong somewhere. Note that you don't need that version. The regular/simpler one is enough.

    EDIT: isn't there a builtin in java about that? or at least something you can build on?

  • Custom User Avatar

    I am not getting stack overflow with your code?

    If you are indeed struggling with stack overflow, I would go in one of two directions:

    • check if your recursion visits places which were already visited, because this might put you in infinite recursive calls, or
    • change recursive approach to non-recursive one, because if the path through the maze is very long, you can get stack overflow even with correct solution.
  • Custom User Avatar

    You're misunderstanding the error message, in Java, it adds those brackets to show where is the difference in the strings. It says:

    Any whitespace at the end of the line should also be stripped out.

    You're removing spaces at the front too.

     Log
    a 
     b               //one space before the b
    c 
    expected:<a
    [ ]b             //one space before the b, the brackets show you where the difference is
    c> but was:<a
    []b              //no space before the b, the brackets show you where the difference is
    c>