Ad
  • Default User Avatar

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

  • Default User Avatar

    Mind that this solution causes UB for space-only (that is also empty) strings.
    Particularly simple but clever regex, tho!

  • Default User Avatar
  • Default User Avatar

    Very much agreed. I'd not want my compiler to warn me about those.
    Thanks for the fix :)

  • Default User Avatar

    Someone explain this magic pls :o

  • Default User Avatar

    The Test cases cause compiler warning if compiled with Clang 8 C++17.
    The fix should be trivial.

  • Default User Avatar

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

  • Default User Avatar

    Oh well, that disappoints me a little. Thanks though for your clarification.

  • Default User Avatar

    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?

  • Default User Avatar

    Can you name an example, please?

  • Default User Avatar

    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) and pageIndex 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 returned 0 instead of itemsPerPage.

    Returning (itemCount() + 1) % itemsPerPage - 1 would be a proper solution instead.