Ad
  • Custom User Avatar

    like i said in my original post, this kata is solve-able by using basic algorithm. You can use library if you want, but by solve it using basic code, the coder will understand how the data flow. The result code might be longer, but it is good learning medium. Then again if the purpose of the coder is want to write code as short as possible then its a different matter.

  • Custom User Avatar

    I'd argue the algorithms in the functions you've listed are pretty obvious (they're all wrappers over a single loop), and that knowing how to use these tools together is more important, but I guess that's just subjective

  • Custom User Avatar

    On the contrary beginner needs to know how fundamental algorithm works. Nothing wrong if you want to use library, but know how to do the same function without using the libray is very useful, especially you need to learn another programming language.

  • Custom User Avatar

    Wrong. By using the libraries of your respective language, you are:

    1. Making your intentions explicit and steering away from imperitive code. JS is a high-level language; you don't need to write C-like code in it.
    2. Using pre-tested code instead of rewriting it.
    3. Reducing code bloat. This solution does NOT need to be 20 lines; you can write it in as little as a single return statement.

    This is really bad advice to give to beginners. The only time I can see this advice as being sensible is if none of the tools in the library offer suitable abstractions for the problem and you're then putting a circle in a square hole.

  • Custom User Avatar

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

  • Custom User Avatar

    this is the best practices imho, without any library.

  • Custom User Avatar

    ah yes, thanks!

  • Custom User Avatar
  • Custom User Avatar

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

  • Custom User Avatar

    Because it's already there at the end of it.

  • Custom User Avatar

    Manage to finish. I must refactor my code to acomodate to new knowledge that you will only get from the testing parameter, why not just incorporate this one example { "NORTH", "WEST", "SOUTH", "EAST" } to the description?

  • Custom User Avatar

    try to remove the break;
    in java, break after return resulting in error. I see you use javascript, might be the same.

  • Custom User Avatar

    no need complex solution to solve this kata, simple brute force method is viable.

  • Custom User Avatar

    Yeah thanks, thats the problem. i forget to sort it. All good now.

  • Custom User Avatar

    But it is not correct? The example shows that expected answer is not [3, 2, 1, 7, 9, 8, 6, 4, 5], but something else?

    There is this example in description:

    Given [[3, 2, 1], [4, 6, 5], [], [9, 7, 8]], your function should return [1, 2, 3, 4, 5, 6, 7, 8, 9].

    What does your solution return locally for the above input?

  • Loading more items...