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.
STONKS always go up
Well done, sir. I consider your oath fulfilled.
I also prefer Oxford commas.
They're nice, unambiguous, and easy on the eyes. ;)
Can we talk about Oxford commas...or the lack thereof. Yes I went there. :)
Yep, readability and maintainability for the win. Regex can be great for performance, but until you minify for production, comments are a must.
So many things to like about this solution, not the least of which it's not ugly (like many think JavaScript just has to be). Nice bit of code.
"pop.pop" - YES. I've never used this in code before, though there were some missed opportunities I shoulda coulda. Waiting for my next chance...
Hmmm, after much coding come to find out that order apparently matters(?) (that is, difference between "read" and "dear" not zero). I was reading the description literally which would have you thinking it a simple matter of of returning min of max(length - hits). This type of code will pass all tests but the last one (i.e. zqdrhpviqslik).
This comment is hidden because it contains spoiler information about the solution
Awesome writeup @cmditch
I found a nicer solution that doesn't use ~
best combo of brevity and readability
It took me a while to figure out what's happening here. In case anyone else is interested.
Basically, any Regexp without closed parentheses will throw an exception, which Insti rescues by returning false. Tricky.
Just punch this in your repl:
The trickier part is tilde. I found the answer here - Stackoverflow & Ruby Regexp Docs very last method #~
It's matching the Regexp to the last 'gets' prompt (only if it's valid, i.e., only if it has closed or no parenthesis). The variable $_ holds the most recent and scoped value of gets, which, in the case of #valid_parentheses is nothing, nada, nil.
For illustration:
This is a beautiful piece of code. Props.
First time my code matched the top result! Usually I get humbled after seeing what other people got, then go off to get smarter on some Ruby method I didn't fully appreciate.
Me no understand. Me go get smarterer now.
Loading more items...