Ad
  • Custom User Avatar

    Added MessageSuppliers to all Assert functions; that should settle this issue

  • Custom User Avatar

    my preferred way is not to randomly decide whether an input is a palindrome or not, but generate some palindromes, generate some nonpalindromes, collect them in a collection, shuffle it, and then use such set to run tests over it.
    This way tests are consistent between runs.

  • Custom User Avatar

    Please consider adding inputs to failed assertion messages.

    See docs for how to do this in C++ kata: https://docs.codewars.com/languages/cpp/authoring#custom-assertion-messages

  • Custom User Avatar

    This looks good :) Now consider my remark about case: the function must be case insensitive, so for things to be done correctly the case of alphabetic characters should be randomly changed (at least in palindrome strings).

  • Custom User Avatar

    Thank you for your advices, I see I had some issues in the translations.

    I rewrote the generator the following way: I kept condition hasToBeAPalindrome but sent it to the generateString function. Next, I generate only half of all characters in the string, and then checked out the condition above.

    If hasToBeAPalindrome == true then I copied the reversed generated substring (except for the last one for odd-sized strings) to the end, else I generated the new portion of data, which highly likely WILL NOT form the palindrome.

    Guess that approach should cover it

  • Custom User Avatar

    You should also add something to shuffle the case of characters in the final string. I would do it this way: first generate a lowercase string (including digits), then make a palindrome or not, depending, and eventually only, change the case of characters randomly.

    If I am not wrong, with the method you have used, palindrome strings should be statistically twice larger than non palindromes. You should fix this too (for example, decide first if it's a palindrome or not, if it is generate a shorter string; or maybe better, this is what I have done in another translation: always generate a palindrome string, and half of times just change randomly one single character).

    To do some manipulations, it may be more handy to create first a vector of characters to work with and then join it to a string.

  • Custom User Avatar

    Thanks, now I forced the validator to manually transform string to palindrome if the random number via random seed if even; that should settle the issue

  • Custom User Avatar

    Random tests almost never generate palindromes (it's possible to pass the tests by hardcoding fixed cases and just return false for the rest). You must make random tests so they generate approximatively half of palindromes.

  • Custom User Avatar

    Actually C++ has but was resolved by hobovsky XD~~

  • Default User Avatar

    4 years later, and no merge conflicts 0_O =D

  • Custom User Avatar
  • Custom User Avatar

    :facepal: changed.

    Also added declaration of solution function in tests.

  • Default User Avatar

    #include <cinttypes> should be used in the solution setup.

  • Custom User Avatar
    • resolved description conflict
    • C header changed to C++ header
    • reference solution moved to local scope
    • reduced amount of random tests (500? really?)
  • Custom User Avatar

    Published a fork with suggested changes.

  • Loading more items...