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.
Fair enough; "inefficient" was a poor choice of word. I was referring more to DRY, and should've said "redundancy".
In three lines of code you manage to calculate the length of
s
three times, the substrings[:i]
twice, and the pattern lengthlen(s) // i
twice. So much inefficiency packed into such a tiny space, it's actually impressive.Clever Kata. Don't listen to the haters, this is a great exercise. However,
The formatting of this passage is pretty gnarly. Since this passage isn't part of the key to the puzzle, I'd recommend rewriting:
Obviously this can be done with a simple dictionary, but I rarely ever use
Enum
so I figured I'd practice. Genuinely curious if usingEnum
here is best practices...?Oooof, I'm embarassed by my pattern now. TIL about
\2
.Super confused by the tests and the description. Are we taking the first
n
unique minimum elements? Or just the firstn
of the sorted elements? Or something else entirely? My current solution only deviates in the last few elements of these long lists, which seems like super strange behavior to me. An example:In the "correct" solution you can clearly see that an 8 is left out. In mine, the last four elements are
[8, 4, 6, 6]
and in the "correct" solution the last four are[4, 6, 6, 1]
so clearly the two are just offset by this one extra element in mine, BUT the "correct" solution includes other 8s, so clearly the "correct" solution considers 8 to be one of then
minimum elements... I don't understand why the "correct" solution throws this particular 8 out when others are let in...Slicing is your friend!
Slicing is your friend!
This comment is hidden because it contains spoiler information about the solution
Two list comps is bad. Rebinding a keyword is even worse. Unreal that this is the top solution.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Enumerate is the obvious choice, but this method is more efficient.
I have no idea what you're talking about. I didn't write a Javascript version...?
Added sample tests.
The automatic "similar katas" didn't show any Katas that were actual duplicates. Can you please link to the Kata(s) this duplicates?
Loading more items...