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.
=)
Seem to be fixed long ago.
I guess this comment was unnoticed :þ. I just saw that «primes» in the spec and I guessed it should be a mistake :þ.
In the spec, perhaps change "primes" to "digits" in "every four consecutive primes".
Thanks for this kata!
Hi , I will look into this thanks for letting me know about this issue appreciate it
Done and dusted !! :)
It'd be good to mention in the spec that discrete hour hand movement is required - snapping to each hour position. I appreciate that this can be inferred from the examples, anyway. Thanks for the kata!
Nice, thanks!
It's interesting that this has to wait until the very end of the input to detect a mismatched closing brace, e.g.
"[)......"
,"())...."
or even just"]......"
.Of course, there's nothing against this in the spec. In fact this is perhaps the elegance of the solution: "We'll stack whatever, but if the stack hasn't been cleared via legitimate matches by the time we reach the end, we know we had a mismatch."
This would only be a problem with a very long-running (or infinite) input stream, where we might want to detect those illegal sequences immediately they occur:
validBraces $ ']' : cycle "(())"
(Just musing as I learn, thanks!)
It'll take only the first match, from the top down. So, yes, you'd have problems if you reversed these two lines, but none as it stands.
This comment is hidden because it contains spoiler information about the solution
Nice!
Minor point:
\w
matches digits and underscore, too, however, so 1000000 becomes abbreviated to 150, and one_two gets abbreviated where it should not, for example.The
\w
in the regex here matches too much. In addition to alphabet characters, it also matches digits and the underscore character, '_'.\w
is equivalent to[A-Za-z0-9_]
As a result, this solution will abbreviate some inputs incorrectly.
For example:
1000000
will become150
where it should be left untouched.snake_case
will becomes8e
where it should bes3e_c2e
left4dead
will becomel7d
where it should bel2t4d2d
abc_
will be abbreviated toa2_
where it should be left untouched.The_300
will be abbreviated toT50
where it should be left untouched.This solution does currently (21/7/2016) pass the submission tests, however!
Here's documentation on
\w
for those who're curious: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#special-word