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.
That's not an issue.
Ah got it! Thanks for clarifying this point! :)
I think you've got it a little confused. Here is an excerpt from the Kata details:
In ["NORTH", "EAST", "WEST", "SOUTH", "WEST", "WEST"], "NORTH" and "SOUTH" are not directly opposite but they become directly opposite after the reduction of "EAST" and "WEST" so the whole path is reducible to ["WEST", "WEST"].
This seems to say that to 'reduce' two directions they must be consecutive. So your example, '['NORTH', 'WEST', 'SOUTH', 'EAST']', can't be reduced further. If it were N-S-W-E, it would reduce to [], but that's not how this Kata is set up.
That doesn't necessarily mean they are correct. Also, take a look at this:
Expected: '['NORTH', 'WEST', 'SOUTH', 'EAST']', instead got: '[]'
Unless I misunderstood the problem -- and please do point it out if I have -- the correct result for the input ['NORTH', 'WEST', 'SOUTH', 'EAST'] is, in fact, []. Or is it not?
The test are correct, 1728 guys passed the JS kata.
The tests for JS are not correct. For instance, it might say "Expecting ["WEST", "NORTH"], instead got ["NORTH" ,"WEST"]". This happens even if the first instance of "NORTH" comes before the first instance of "WEST" in the argument variable. Frustrating.
I have exactly the same issue. Solved the problem, on my irb everything works perfectly fine, all the tests are passing, yet the Attempt to submit final fails.
The expected and the actual are swapped around, so your solution is returning 15 and the expected answer is the result it said your solution was returning. I would change it but unfortunately I can't modify the testcases once the Kata has been approved.
In Java, it says that the expected output is 15, which contradicts the instructions (it should only be one digit)
Nope that's not the goal. The problem with looking at other people's solutions is that they might be further down the line in expertise. Like Dahlia said, it will become more natural with time.
My coding instructor taught us to try to achieve succinct code in this manner, in sequential order:
And ultimately, don't strive to cram everything in one line. I think that's just being silly. Yes it's cool, but a lot of times I'll find a one-liner to be not as human readable as a 3-5 liner. The goal is to strike a good balance between readability and efficiency. (And more lines of code doesn't necessarily mean less efficient code - a nested
for
loop takes only 5 lines in JavaScript but can be really inefficient.)According to the requirements the output is correct, however, they are not passing the expected values for the test.