Ad
  • Default User Avatar

    In the spec, perhaps change "primes" to "digits" in "every four consecutive primes".

    Thanks for this kata!

  • Default User Avatar

    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!

  • Default User Avatar

    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!)

  • Default User Avatar

    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.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    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.

  • Default User Avatar

    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 become 150 where it should be left untouched.
    • snake_case will become s8e where it should be s3e_c2e
    • left4dead will become l7d where it should be l2t4d2d
    • abc_ will be abbreviated to a2_ where it should be left untouched.
    • The_300 will be abbreviated to T50 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