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.
Ok, with Java is then out of my hands: post under the Java translator comment, so that he can be notified.
Cheers!
This solution is really Java. Java streams are part of Java 8 and you can program in a functional way (albeit in an extremely verbose way) in Java 7. Java is a multi-paradigm language. Actually this solution could be better if it did away with array indexing altogether (e.g. strArr[i + j]), and use streams entirely.
You are right that the solution is inefficient at O(n^2).
This comment is hidden because it contains spoiler information about the solution
Which language? And feel free to share your code with a spoiler tag here :)
This is a very neat recursive solution. However, it's unneccessary complexity to use recursion.
This comment is hidden because it contains spoiler information about the solution
If I read the solution code in the test cases correctly, it's O(m x n), where m is the seed length and n is the number of values to be generated. IMHO, this is a sub-optimal solution. It can be implemented in O(n).
This solution is O(n x m), where n is the number of values to be calculated and m is the seed size. There is no need for the m term; the solution can be completely O(n). The initial Arrays.copyOf() is more clever than what I did.
Admirably terse, with no text for whether or not n is less than or equal to the seed size.
I tagged this as "best practices" because of the simplicity compared to other solutions. It is, however, order of m*n, where n is the sequence length and m is the seed length. order of n is possible, although not important where m is a constant.
Lovely. I couldn't figure out how to use streams since I was thinking of doing the map on the value of the character. Doing the map on the index instead solves that issue. Very clever.
Thanks. One thing that may color my outlook is that I learned programming back in the 1960s. Computer time was massively expensive. Programmer time was relatively cheap. Efficiency was paramount.
The definitions of these are:
Efficiency is valued in Codewars and this question has been asked many times as well as the topic has been debated many times (see here). Many of the coders on Codewars (like myself) have no experience coding at industrial standard or have no/little knowledge on efficient coding (such as space/time complexity). These skills are learnt at a more specialist level and therefore not everybody considers efficiency when they look at a good solution, they look at code length instead.
However, in my opinion, efficiency is not the most important thing when it comes to coding smaller scale projects. Efficieny is a thing to look out for and try to manage. I try to structure my solutions with a "good balance of performance, readability and maintainability". I have learnt a lot during my time at Codewars and now try to keep thing compact yet efficient, but others may not have this knowledge and continue to mark these as "best practice" if the code is short. I do like one-line solutions (as long as they aren't too long) since they are snappy, to the point, simple and usually understandable.
This comment is hidden because it contains spoiler information about the solution
This looks like a Python or Javascript solution written in Java.
Truly neat functional programming, but it's inefficient and it's not really Java.
Loading more items...