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 all of these to description
There are no negative numbers in test, but yes. It must be specified
Also, the task asked for in this kata is basically already covered by
std::snprintf
(andstd::format
for C++20 and above). There is not much reason to reinvent this wheel in a language where this is built-in.First, it is actually 6 decimal places, because you didn't configure the precision. Second, rounding can happen if the number has more than 6 decimal places, but this is not tested.
Negative numbers are not tested either.
There are no random tests.
why do we have to return an empty array if no string is given?
Hello, the issue was in my code, that i tried to access an element on an index that is more than
std::string.size()
, which put'\0'
in somewhere else in the variable.if someone made a pull request to snowhouse to encode strings better, they might just accept that and then it would apply to all cpp kata
if it's considered (past) the end of the string, then why is it included in the error output?
https://github.com/banditcpp/snowhouse/issues/40
https://github.com/banditcpp/snowhouse/blob/8db10c8114e520ed4ee05dea850d671b32af049c/include/snowhouse/stringize.h#L90C36-L90C36
Unfortunately, this is something what can happen in C++ and it's not easy to do anything aobut this. Your solution has a bug, and at some place it puts
\0
into some of the pieces. Later, the failure message is build, the\0
gets in a middle of it, and when printed, everything beyond the zero character gets cut off.In your example, your first chunk is
"a\0"
, and when it is used as a part of the failure message, the message is not printed fully because the\0
is considered he end of the string.I can see how it is a problem, but it is not a bug in the kata, and it's not something what can be fixed very easily. Unfortunately, some low-level languages are like that, and C and C++ are the most common offenders in this regard.
Writing in C++, i got an error on tests:
This error messages are invalid. Even if my code was wrong, it's not possible to send an array/string without closing symbols : quote and brace.