Ad
  • Default 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 ;-)

  • Default User Avatar

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

  • 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!

  • Default User Avatar

    [],
    [0, 0, 0, 6],
    [],
    [],
    [],
    [6, 6, 0, 0, 0, 6],
    []

    I need your help:) Looking at the instructions on this "testTrickyQueues" input I understand (and this is what my code does) is that:

    From the bottom, the first "passenger" in queue seeks to go down - thus the Direction of the Lift is set to DOWN.
    Since there is someone on the 5th floor (3 "passengers" actually) who also seek to go down, lift should me smart enough to regonize this and:
    firstly go to floor 5, pick 3 "passengers" than on the way down on the floor 1 collect 2 additonal "passengers" and let 5 pepole out on the ground floor.

    So now the queues on each floor look like this:
    [],
    [0, 6],
    [],
    [],
    [],
    [6, 6, 6],
    []

    With this logic, the output is at this stage is:
    [0, 5, 1, 0] and there are still "passengers" awaiting.

    I'm failing 2 from 16 tests, one of them is "testTrickyQueues" and it says that:
    arrays first differed at element [1]; expected:<1> but was:<5>

    Meaning that we should ignore the fact that on the 5th floor three pepole are willing to go down and pick up the passengers from floor 1.
    Which doesn't make sense considering the instructions but I MIGHT simply misread them

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    Hey g964, thanks for comming back :) Yeah, I just realized I was reading this incorectly;P my bad

  • Default 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?

  • Default User Avatar

    Since it's expected to raise the elements of the array/list (the base) to the power equal to the base itself, as shown here:
    "solve([2, 1, 3, 4]) returns [2, 11] :
    (22 + 11) * (33 + 44) = 5 * 25 = 125 and 2 * 2 + 11 * 11 = 125"
    then,
    shouldn't this:
    "P = (x(1) ** 2 + x(2) ** 2) * (x(3) ** 2 + x(4) ** 2) * ... * (x(m) ** 2 + x(m+1) ** 2)"
    be this:
    "P = (x(1) ** x(1) + x(2) ** x(2)) * (x(3) ** x(3) + x(4) ** x(4)) * ... * (x(m) ** x(m) + x(m+1) ** x(m+1))"
    ?

  • Default User Avatar

    Would anyone be able to help:)? I'm getting errors saying that I'm not returing anything. Well, it's not the task to return, but to call the count() method with the correct parameter which I do ;|

  • Default User Avatar

    Is the implementation of counter() method taking care of returing the i? My code is running properly on my local machine (where I've implemented a simple Counter class with counter() and a println) but when I migrate the countInThreads logic to this kata it fails. I wonder what's the implementation of Counter class here

  • Default User Avatar

    This is a really nice Kata:) Thank you. The only thing which strikes me is that the 'Battleship field validator II' kata is like 2-3 times harder to solve but it's the same kyu level

  • 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

  • Default User Avatar
  • Loading more items...