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.
Nice, didn't realise there was an O(n) solution!
Might very well do that! Been considering to follow your example and make some Erlang katas. Seen several of yours.
I don't know, hard to say! Well enough I guess. And coding is coding.
Yup, that fixed it! Thanks for solving it quickly
It might be somewhat slower, but I'm not sure. I think sorting the results is a perfectly adequate solution.
My solution? I haven't been able to submit one.
Aha, are you using a map? https://www.erlang.org/doc/efficiency_guide/maps.html#how-maps-are-implemented
At N <= 32, erlang OTP maps are stored as flatmaps, so you can probably get away with a simple maps:to_list... However, for N > 32, they use a more complicated data structure, and more importantly, the order of the elements is not well-defined.
I map get to generate the actual list, something like this: lists:map(fun(I) -> maps:get(I, Map) end, lists:seq(0, N-1))
This comment is hidden because it contains spoiler information about the solution
@g964
For the erlang version, the test suite is faulty. The output lists in parts 'random1' and 'random2' are not in the correct order.
Encouraging post! This will be the first and only kata I do in the series, as the previous are not available in the language I'm practicing. Looking forward to it!
True, the fact that the alphabet is limited makes my analysis too pessimistic.
A standard implementation of str.count(char) entails an iteration through the elements of str. Without knowing the details of the Python implementation, it is most likely still an expensive operation. The solution is far from optimal and shouldn't be considered best practice. "Too slow" still holds.
You can solve the problem and only loop through s1 and s2 once respectively.
This comment is hidden because it contains spoiler information about the solution
This is very inefficient