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.
Based on the tags, I'd assume the author intended a regex solution but I would always endorse built-in functions when they're more succinct and readable. :)
This comment is hidden because it contains spoiler information about the solution
So even in such short a description you managed to miss a whole sentence...
Well, the kata says it takes place in the desert, and while I guess you can have insurmountable dunes, it does not include such enitites in the description (which would be an entirely different problem). The drawing above is furthermore misleading - on the left hand side you go 2 steps east, then 1 north (even if it is drawn as 2 east, 2 north) while on the right hand side it is 3 north, 1 east (again, drawn as 3 north, 2 east). Assuming that each step of the instructions are all of unit 1 (otherwise,
SOUTH NORTH
would not necessarily end up the same place), the drawings really reprents the two pathswhich are clearly not the same thing.
The kata really only need a few words to make the task more clear, such as to say what is meant by not reasonable i.e., two consequitive steps in opposing directions.
I think the confussion comes from the fact that naturally takes the set of operations
{NORTH,SOUTH,EAST,WEST}
as commutative and associative. That is for any three operatorsa
,b
, andc
in the setbut the test breaks that intuition. What the test seems to say is that operators in the same vertical or horizontal direction are commutative
but not between horizontal and vertical directions
nor are the operations associative between vertical and horizontal
(this may seem odd, but on the left-hand side the
(NORTH SOUTH)
is the identity, but on the right hand side(SOUTH EAST)
does not reduce). Thus, the kata is really dealing with two algebraic groups{NORTH,SOUTH,id}
{EAST,WEST,id}
for which the convolution operations are commutative and associative within each group separately but not between the groups. This, I think, is not how people read the kata - they think of the single algebraic group
{NORTH,SOUTH,EAST,WEST,id}
with a single convolution operator.
Are you sure?
If you get different result, then you're reducing the array wrong somehow.
Yes, it was, but you mutated it.
The error is right what the error message says: you're trying to reverse what you're expecting to be an array while, in fact, it's an
undefined
value. Also, passing the sample tests doesn't mean that you will definitely pass the main tests.Not a kata issue.
You're trying to access a position of an array or subarray that doesn't exist. It's a problem with your code not an issue with the kata. In javascript each test shows the input (you don't need to use console.log for that). Beware of mutating the input, if you do that, the array shown in the tests will be wrong.
Answered.
No, it's already in the instructions: