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.
Why did you remove whitespaces?
Yeah, i passed all tests but was length error, i just checked if arrayOfArrays is null and returned 0 if it is null
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.
Warning: Executing JavaScript from a string is an enormous security risk. It is far too easy for a bad actor to run arbitrary code when you use eval()
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.
༼ つ ◕_◕ ༽つ
Loading more items...