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.
I got it!!
sorry, my fault!
A very interesting kata!!
Well done JorgeAbad! You are quite the peristent character, a very good trait to have in programming. Good work mate.
THANKS, THANKS, THANKS, THANK YOU !!!!
Chrono79 and joh_pot !!!
I have it!!! I have suffered a lot but now I'm very happy... "no pain, no gain". It has been worthwhile to persist trying.
A bright kata to search the best, and no simply a "good" solution...
Object key-value. I don't want to spoil too much, but think of a way to only run once over each string.
Chrono97 Do you say object key-value or an object array? I've tried arrays, array methods, array lodash methods... same result, 60 test ok, but timeout on performance test.
joh_pot: I think I understand the basic problem in this kata. But at least, str2 must be read one time for chars, and so str1 to check if it have the chars in str2 and in the needed number... surely there is another method that is the one that I can not find to solve this.
I do not want to give up!!!
Look at your strings. Lets say str1 is 'abcde' and str2 is 'cab'. In order to see if this will return true, you need at least 1 'c', 1 'a' and 1 'b'. Determine using the other str if you have those amounts.
The answer is no. It's easier than that. Try using an object.
OK.
But I do not get it, and my self-esteem is at the level of the soles of the shoes. :-(
Should the correct solution employ some kind of complex sorting algorithm, or some recursion?
There are 50 random tests with string lengths between 0 and 500 and then 4 performance tests with string lengths of 500 000
In the initial tests, which are 8, my code takes, for example, 300ms. How many tests are done in the final attempt? to be able to estimate what time of execution of the initial 8 I would be worth to run the full tests.
Thanks joh_pot that must be the problem, but with two array methods... although, in fact, one of the methods I use does not cover the entire array, but only until the first occurrence.
I need find another solution.
Hi JorgeAbad. Array functions are usually O(n), which basically means that it will run through every element that exists in it, it's a hidden
for
loop. So if you have code for exmaple like this:That is 2 nested loops, even tho you explicitly only created one, which could blow up your execution time. So just be wary of these "hidden" loops inside array functions,
My last code use a array method and a lodash functio for array...
Loading more items...