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.
This comment is hidden because it contains spoiler information about the solution
Mind that this solution causes UB for space-only (that is also empty) strings.
Particularly simple but clever regex, tho!
This will accept many illegal string like
][
.Very much agreed. I'd not want my compiler to warn me about those.
Thanks for the fix :)
Someone explain this magic pls :o
The Test cases cause compiler warning if compiled with Clang 8 C++17.
The fix should be trivial.
I wonder if arrays with negative values generated in
randonTests()
are intended, since they're very rare (only about 8%) and never mentioned in the description.If they are, it should be mentioned in the description and the rate of occurence or the amount of random tests should be increased, since this low rate would regularly allow solutions, that disregard negative values (like mine did).
Oh well, that disappoints me a little. Thanks though for your clarification.
I appreciate your response and see your point. However, personally, I'd not take that as an argument to allow even further faulty submission, because that would make the concept of this whole game pointless, wouldn't it?
Can you name an example, please?
For Java a (rather important) case for
pageItemCount(int pageIndex)
is not tested.This (missing) test would prevent a very intuitive implementation that is actually wrong when the last page is fully filled (
itemCount() == pageCount() * itemsPerPage
) andpageIndex
is the last page (pageIndex == pageCount() - 1
) at the same time.Returning
itemCount() % itemsPerPage
(which is also used in the solution voted as best practice) would be wrong since it returned0
instead ofitemsPerPage
.Returning
(itemCount() + 1) % itemsPerPage - 1
would be a proper solution instead.