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.
In fully half of the cases, the random tests expect the entire string quoted back because
max >= string.length
.Bit of a waste of tests. Better to have
max < string.length
more often.There's still exclamation marks without spaces after them, and the reference solution still bugs out on that.
I think my own solution is still buggy as well, but I'm getting a bit tired of having to check the reference answer first all the time.
Please, please, please, fix your kata. (insert expletives sprinkled generously throughout. sigh.)
I think I've fixed this problem now...? I've also updated the description.
"..: vw..."
fits in39
characters exactly. The reference solution may still contain a bug.In that case, I'd specify in the description that a punctuation character will always be followed by a space.
Very true. I think I've fixed this by using your first solution. Thanks again!
Yep, that's fixed.
Generally, punctuation separates words, doesn't it? If it doesn't, that's OK, but you should explicitly, and clearly, specify that I think.
If you actually wanted spaces after punctuation anyway, one solution would be to run a
String.replace( /punctuation/, "$& " )
on the generated random input ($&
expands to the matched string). You'd have to trim any trailing space. Or you could generate separate words in an array (of random length), randomly append punctuationto the ends of some words, thenArray.join(" ")
then together. That prevents any trailing space in the first place.Thanks again! I didn't know how to make the random strings always include a space after punctuation so for simplicity's sake I was considering the punctuation as part of the 'word'. Is this confusing? Do you have any advice on how to improve this? This is my first attempt at authoring a kata so really appreciate your help.
There should have been a space either side of the dash - that should be fixed now. Thanks for spotting.
From the random tests:
Does punctuation not separate words?
Why not
"1801-I..."
?