Ad
  • Custom User Avatar

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

  • Custom User Avatar

    I did read the description/instructions in their entirety before voting and I'm saying I don't understand from the description how to achieve the intended solution. I understand that I'm supposed to create a 2D array based on the townSize parameter passed in. I then understand that I'm supposed to snake (traverse) through the 2D array depositing an incremented value that shows the path taken through the 2D array. I understand that a -1 means to go left/up, 0 means to go left or right/up or down, and 1 means to go right/down (street/avenue).

    I don't understand where I'm supposed to start in the 2D array or if it's assumed that I have to start at index [0, 0]. I don't understand how the values in the streets and avenues parameters relate to my current position in the town. For example, given your example compute(3, streets, avenues), how do I know to start at index [0, 0] (where I would deposit a value of 1) and move right? From your instructions, a 1 would allow me to move right and a 0 would allow me to move left or right.

    I'm not trying to be mean, I'm trying to be helpful and understand your kata. The first step would be to learn how to edit the kata. The next step would be to ensure that the return value of the compute function will pass your Test expectations. Your first test expects [[1,2,3],[6,5,4],[7,8,9]] as a return value. If I write this inside the compute function: return [[1,2,3],[6,5,4],[7,8,9]];, the kata still fails. I tried wrapping it in a string and also tried stringifying it with JSON, which neither worked. So I believe you have issues with your Test fixture comparing array values. I pointed this out in my previous comment and how to solve that because as it stands, this is what happens: Test Failed: Expected: [[1,2,3],[6,5,4],[7,8,9]], instead got: [[1,2,3],[6,5,4],[7,8,9]]

    So it's an interesting concept for a kata but I don't think it's ready.

  • Custom User Avatar

    I run your code and indeed it should work when there is no tail. But all the test cases (except the first) have a tail and a loop so your code won't work which is normal.
    What it returns is the size of the tail + loop not the loop only.