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.
If you have enough time you could try https://www.codewars.com/kata/5772382d509c65de7e000982/train/erlang and tell me if you see problems. It's so rare to find someone who uses Erlang:-)
I don't know, hard to say! Well enough I guess. And coding is coding.
A big thanks to you!!! Do you well know Erlang?
Yup, that fixed it! Thanks for solving it quickly
I modified the translation. Your solution should work. Can you give it a try?
It might be somewhat slower, but I'm not sure. I think sorting the results is a perfectly adequate solution.
I now understand the problem for N > 32. I think the simplest thing to do is to "lists:sort" my results. What do you think of that?
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))
I tried your first solution : it passes. Actual and expect outputs are in the same (wrong) order.Your second solution doesn't pass : actual and expect don't have their elements in the same order (your actual output seems to be in right order).
I don't understand what happens; with small numbers (N <= 32) the order is correct. From N = 33 the order is weird. Can you help?
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.
That's what the "Clever" rating is for, code that is more creative than efficient. I think we could all benefit from bringing more creativity to the programming space
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!
Loading more items...