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.
Aiight imma stop fucking around with this stupid one liner now, and actually go to sleep.
I admire ethat OR operator. Clever dawg.
Pretty much what I wanted to do, but couldn't find anything about how to use existing libs to format HH:MM:SS. Only found old arse posts about Date and Calender.
Groovy solutions there, very nice.
Just FYI, you did not had to trim out the spaces in "time", if you had split it as: ", " rather than ",".
I just want to point out that:
bits.replaceAll("^0+", "").replaceAll("0+$", "");
Can be shortened to: bits.replaceAll("^0+|0+$", "").
The "or" operator is a handy sign~
I forgot to point out in-code, that the reason when I check the min-sequence of 0s and 1s, only 1s have the filter-function -- is because 0s are always trimmed out at the start & end of the string, and primarily because of how the split function works.
That means that when splitting out the 1s, it is likely to return an array with empty cells, which needs to be filtered out.
I.E: "11100111" will be split into ("1+"): ["", "00", ""]. Empty cell = returns length 0 instead of 2.
Out of all the 5 kyu I have done, this one had to be the easiest by far. Even without built-in neat tricks like in Javascript which make base-hopping absolutely trivial.
Oh well, guess I at least learnt something about RGB conversion.
This comment is hidden because it contains spoiler information about the solution
Looking at the answers, I truly do not understand why this was labeled as "regex", pretty much nill regex was ever used in most of the answers.
I like this one, I'm going to look up more "puzzles" in the future.
That being said, it feels like it's inescapable from feeling like a "cheating smartass" when solving this, since conditionals are not totally out of the question. Just "if".
At least, going by the answers, that's how it seems like.
Ah, I completely forgot about switch/case.
...What the hell are we even looking at? What does this even constitute as, seeing as the function name is completely missing? How the hell does this even work?
EDIT: Pft, I see, okay. I didn't know that compilers allow this sort of shit.
OP took his code and encoded it to UTF-16.
Looking at the top solution of this problem, I feel like I was so close, yet so far, with my usage of "$1$2" for symbols. God damn it.
It has to do with the versions you work with, most likely. For an instance, in JS, NodeJS supports "replaceAll" only at versions 12+. Codewars uses 8.
You may need to find workarounds to your solutions, with functions that exist in older versions.
Apparently it's advisable to not use /d if you can, since it may cause "escaping issues in some languages (like Java)."
(However much that's worth, just putting it out there)