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.
As a word of caution to future professional developers:
I'd be leery of using
match
with a string. This turns into a regex, which has special meaning. Ifarray1
contained any strings with non-letter chars, like'.'
, thematch
would trip up certain tests.e.g.
'hello'.match('h.l.o')
returns a match.Also, if someone were trying to be malicious, it could be worse (could potentially crash things).
e.g.
'hello world'.match('(((((((.*)*)*)*)*)*)*)*x')
, in Firefox, freezes for a few seconds.It's not clear for certain cases when and which cars the algorithm should turn away.
For instance, given,
I think Dave's gonna say no to just the first guy seeing he can then turn away only 1 vehicle instead of 6 (since the first guy would otherwise be stuck in the front). The prompt doesn't make it clear enough, though, as to what to return in this case.
If it's made clear that the goal is to achieve the minimal value, then the puzzle becomes much more interesting (albeit a lot harder), but also requires additional tests to ensure cases like the above are satisfied correctly.
If getting the minimum isn't required, then it really should be made clear that, for certain cases (like the above), multiple return values are accepted, as long as they don't turn anyone away unnecessarily (although, this makes generating random tests probably a bit difficult).