Please read the earlier comments in this thread. You will see that you are not the only one having problems to solve this kata. Simply looping through the list is too slow. Try to search for articles about datastructures that can sort or search arrays very efficiently and you will find what you need.

In the Haskell Sample Test "should perform many-to-many JOIN and apply WHERE" a comparison without spaces is present. The EBNF-scheme therefor is not exactly correct, but imho this is not a big problem.

In your code you effectively change the input array trips. You can find that out if you do a console.log(trips) just before you return your result. If you don't change the input array, your answer will be accepted.

I think I found the problem. In your code is the line item[0]++ . This effectively changes the trips array in such a way that only trips of zero days remain.
You can solve this by placing var x = item[0] in front of your while loop and replace every occurrence of item[0] with x.

To check this do a console.log(trips) just before you return your answer.

This probably is a known issue, and I would like to resolve it for you, but I don't understand what goes wrong in some javascript solutions.
This was also reported by jlb071 in an earlier post.

More or less it means that the consumed execution time of your program grows quadratically with the size of your input. If an algorithm has time complexity O(n), the execution time grows linear with respect to the size of your input. A start page for further investigation is this one, but there are a zillion more.

If you have an array with n elements and you visit each element n-times you have an algorithm O(n^2) and that is less efficient than visiting each element only once (O(n)).

This kata's sensei hasn't been around since february 2018. Little chance this kata will ever be approved I guess.

Great kata that deserves more solutions. Thanks for creating it.

This solution is exactly the same solution as the reference solution, even the comments are the same. This must be a very big coincidence ...

Only //what? is added to not get a copy solution.

More equal solutions ...

This one and this one.

Another one:

This one and this one.

First example:

By eleminating E W and S N combinations N N N remains. Nothing wrong with this kata.

Great kata. Listen to this while finding a solution.

Real life coding challenges are defined whith less clear requirements most of the time.

It is even possible to extend this by thinking that 18 is odder than 24.

Take a closer look at your loop declaration.

No wonder that your beans! are missing from the log I guess. (> != <)

Cheers

Please read the earlier comments in this thread. You will see that you are not the only one having problems to solve this kata. Simply looping through the list is too slow. Try to search for articles about datastructures that can sort or search arrays very efficiently and you will find what you need.

Cheers.

Java translation is ready for review.

Your seventh column has two ones, and your eighth column has two eights. So, I'm sorry to say, but your answer is wrong.

Correct solution:

In the Haskell Sample Test "should perform many-to-many JOIN and apply WHERE" a comparison without spaces is present. The EBNF-scheme therefor is not exactly correct, but imho this is not a big problem.

In your code you effectively change the input array trips. You can find that out if you do a console.log(trips) just before you return your result. If you don't change the input array, your answer will be accepted.

Cheers.

I think I found the problem. In your code is the line

`item[0]++`

. This effectively changes the trips array in such a way that only trips of zero days remain.You can solve this by placing

`var x = item[0]`

in front of your while loop and replace every occurrence of item[0] with x.To check this do a console.log(trips) just before you return your answer.

Cheers.

Hi,

This probably is a known issue, and I would like to resolve it for you, but I don't understand what goes wrong in some javascript solutions.

This was also reported by

`jlb071`

in an earlier post.More or less it means that the consumed execution time of your program grows quadratically with the size of your input. If an algorithm has time complexity O(n), the execution time grows linear with respect to the size of your input. A start page for further investigation is this one, but there are a zillion more.

If you have an array with n elements and you visit each element n-times you have an algorithm O(n^2) and that is less efficient than visiting each element only once (O(n)).

In the second example:

the last tuple (2,3,4,1) should have two inversions. I see three, i.e. (2,1), (3,1) and (4,1).

Shouldn't the last one be (2,3,1,4)?

## Loading more items...