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.
Added MessageSuppliers to all Assert functions; that should settle this issue
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.
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
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).
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 thegenerateString
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
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.
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
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.
Actually C++ has but was resolved by hobovsky XD~~
4 years later, and no merge conflicts 0_O =D
:facepal: changed.
Also added declaration of solution function in tests.
#include <cinttypes>
should be used in the solution setup.Published a fork with suggested changes.
Loading more items...