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.
Well, description limits n to 0 <= n < 1000000000. I think gsub(/.../, '\0,') would be shorter and faster than scanning for variable length.
nice
One char longer than my solution. :P
Or if not display the exact input, at least give a hint as to what sort of input is causing the failure.
You're welcome! So glad I could be helpful. :)
missmaggiemo, thank you for pointing out some flaws in my test cases, now corrected.
Hmm, I clearly haven't made it clear :-) that the objective is to validate the string.
New wording "This method accepts a single argument, a string to be validated.
The string can be of any length and have any contents. But to be considered valid, it must have zero or more blanks followed by zero to eight numeric digits followed by, again, zero or more blanks.
If it is valid, the number within the string + 1 is returned. Otherwise, the string 'invalid' is returned. A completely blank string is considered valid, equal to zero.
' 7 ' returns 8
' a 8 ' returns 'invalid'
' ' returnss 1
'abc1' returns 'invalid'
An easy problem.
The only slight challenge is to produce a simple method that has no regular expressions and no nesting; no explict nesting with 'for' or 'while' or whatever, no block nesting with things like 'map' or 'each'; obviously I have no way of enforcing this!"
I think this problem needs either a better explanation of the expected input (e.g., inputs will include only a string of letters and/or numbers surrounded by spaces, but there will be no spaces in between the numbers/letters), or better explanation as to what the expedcted output of, say, " 1 8 " or " 0 " would be.