Ad
  • Custom User Avatar

    That's not an issue.

  • Custom User Avatar

    Ah got it! Thanks for clarifying this point! :)

  • Custom User Avatar

    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.

  • Custom User Avatar

    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?

  • Default User Avatar

    The test are correct, 1728 guys passed the JS kata.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Default User Avatar

    In Java, it says that the expected output is 15, which contradicts the instructions (it should only be one digit)

  • Custom User Avatar

    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:

    1. it works
    2. it works well
    3. clearly it works well

    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.)

  • Custom User Avatar

    According to the requirements the output is correct, however, they are not passing the expected values for the test.