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.
The current solution upvote system slightly rewards shorter code over efficient code on many problems. I think this might change in the future if they decide to show the average runtime of each solution.
+5Kyu kata check for efficiency more often as a requirement to pass the tests. On lower level kata, you can mostly expect short solutions that are far from being considered best practices.
Other reason for writing shorter code is simply having a little bit of fun. I've done it myself.
Hello Diego. I think It's an ingenious use of Map and Reduce but those methods are unnecesary in this case as they make you go twice through the array when you only need to traverse it once. The Map/Reduce also make the solution harder to read in this case, in part because of how you wrote the code.
Best regards and feel free to ask me anything and I'll get to it if I can help you. You are on the right track in any case and mainly need to focus on making your code cleaner.
To summarize a lot, code that is "best practices":
Sometimes, if the function is simple enough, you can accomplish all this with one line of code. Usually, however, you can't. Many one-line solutions have poor time complexity, since they often use array methods that make the complexity at least O(n^2). If they don't have poor time complexity, they are often hard to understand for a less experienced collegue.
If your code is properly split into many simple and clear pure functions, many of them can be one liners and they will be easy to understand because they are doing just a single thing. But here you will usually see one-liners that are a long, inefficient chain of high order array methods.
That being said, writing one line solutions can be extremely fun and I often do it. But they should never be voted as Best Practices.
If you are interested in learning more about best practices and clean code, you can search the work of Robert C. Martin. That man has great books on programming and many talks on youtube, and he gives examples based on real-life work situations that you could encounter while coding in the future.
It's harder than most 7kyus. Katas that have been approved recently tend to be harder. Try sorting 7Kyu katas by a criteria other than "Newest" and see how difficult you find those.
This comment is hidden because it contains spoiler information about the solution
You are not returning the value (●'◡'●)
Hello! What you are logging on items there is strange, since "items" is the input that you must scan/parse to check how long is the longest consecutive sequence of "key" in it. It's likely that you slightly misunderstood the problem or that there's a mistake in your code. I and many others solved this with a very simple and straightforward solution and the kata worked just fine (it isn't broken).
Case 3 is amazing and opened my mind a bit more.
Wonderful solution, I'm glad I read this.
Truly excellent Kata. Upvoted.
What a God. This has better time complexity than the other solutions.
The test says that ten people are left out! Read the problem again.
༼ つ ◕_◕ ༽つ
You are well on your way to being a great programmer. You don't lack an innate capability or intelligence if you got this far!
This comment is hidden because it contains spoiler information about the solution
This Kata was surprisingly difficult for me and I enjoyed it very much. I learned something new by solving this and by reading the other solutions.
Thanks (●'◡'●)
Loading more items...