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 didn't you write return n * 2 - address + 1;?
Avoid? No. Just use them with double backslash in RegExp constructor.
So, are you saying that we should avoid All the built-in character set such as
\d
,\w
,\s
, etc?\d
is not the only char set that have a backslash (escaped). How about other escaped characters that we can't construct manually such as word boundaries? (\b
&\B
) ?Do you mind me asking how you came up with that? I never would have thought of it.
Thank you so much
great solution!
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
Same for Javascript, but only if we use new RegExp(regString) constructor.
We must use \\d instead of \d. Or [0-9]. Or String.raw`\d`
Loading more items...