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.
Yep, I know and already provided another solution.
The thing is that there is no check for odd number of the same letter in this Kata.
That's why I proposed to add 'aaa' test case.
So your code fails when there is an odd number of the same letter.
This comment is hidden because it contains spoiler information about the solution
There are already tests with
"a"
and"aa"
as input (at least in Python and Javascript). Which language are you talking about?Hi!
It would be great to add test cases like 'aaa', 'aa' and 'a'.
I found a solution which could pass all tests, but can't handle 'aaa', 'aa' and 'a'.
Seems that test cases were chaged after this solution.
'http://google.co.jp' returns 'co' instead of 'google'
Thenks for finding an edge case Mincer!
Sadly, at this point such a change might invalidate a good number of solutions, and I'm not familiar with the process involved there for CodeWars.
The tests also do not have random list tests, and do not protect from user manipulation of the data sets.
As this problem is now a little over 6 years-old, I'm inclined to leave it as-is. Particularly, due to the fact that as a method to teach people about the power of limiting array traversals and the usefulness of hashmaps, it still fulfills that need.
That's why I ask to add such test case to avoid accepting non universal solutions.
Hm, re-check your solution again. Universal solution can handle datasets like this....
What do you think about adding sum_pairs([12, 4, 5, 3, 8, 7, 5, -2], 10) in test cases?
In such dataset you can find 3 nested pairs: [12,-2], [5, 5], [3, 7] where [3, 7] is the right pair.
The thing is, that I wrote solution, which passes all tests and successful at attempt, but can't handle provided dataset because it has 3 nested pairs.
Including sum_pairs([12, 4, 5, 3, 8, 7, 5, -2], 10) will help avoid wrong solutions.
This comment is hidden because it contains spoiler information about the solution
Great tip -- really pushed me over the edge. Math the solution not code.
I had solved the test with loops but timed out. Saw your tip and A HA! I solved the tests with a totally new approach (no loops) but it still times out. Grrr EDIT: Another commenter here mentioned sorting the arrays itself will cause a timeout. Although I did remove the for loops I had left the code to sort the array even though it wasn't necessary anymore. Problem solved.
This comment is hidden because it contains spoiler information about the solution
Three different ways with less than 1s for tests and still timing out
Loading more items...