Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
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, and1
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 thestreets
andavenues
parameters relate to my current position in thetown
. For example, given your examplecompute(3, streets, avenues)
, how do I know to start at index[0, 0]
(where I would deposit a value of1
) and move right? From your instructions, a1
would allow me to move right and a0
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.
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.