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.
While the current tests are comprehensive, the following could add even more robustness:
Empty String:
Test splitting an empty string: split("", ' ').
Expected result (strip = false): {""}.
Expected result (strip = true): {}.
Single Character Input:
split("a", ' ') should return {"a"}.
split("-", '-') should return {"", ""} for strip = false and {} for strip = true.
Buffer Size:
Verify behavior with long tokens exceeding BUFFER_SIZE to ensure correct truncation.
Example: split(std::string(70, 'a') + ",b", ',', false).
Non-Printable Delimiters:
Test with special characters like \t (tab) or \n (newline).
This kata "assumes" that you should have OOP basic knowledge.
"Additionally, this Kata assumes that you have basic knowledge of Object-Oriented Programming ( or a similar concept ) in the programming language you are undertaking. If you have not come across Object-Oriented Programming in your selected language, you may want to try out an online course or read up on some code examples of OOP in your selected language up to ( but not necessarily including ) Classical Inheritance."
Although, this is not necessary because you don't need that. The language can be not object-oriented (like C) neither the algorithm requires and/or uses inheritance.
I suggest to remove this paragraph for better clarity.
Is it possible that your function is returning a string rather than an array? That would explain the part of the error message:
for 2nd argument std::string
.I'm marking this as resolved. I don't think it a kata issue.
Can you please describe what you did that led to this error? When I test everything it works fine. Also, other people have solved the kata in C++ without encountering this issue.
In C++ programming language, code shows
std::vector<std::vector<int>>
as a result when test expectsstd::array<std::vector<int>, 2>
In file included from main.cpp:7:
./tests.cpp:4:29: error: no matching function for call to 'validateTwoSetsOfEqualSum'
auto verification = validateTwoSetsOfEqualSum(i, createTwoSetsOfEqualSum(i));
^~~~~~~~~~~~~~~~~~~~~~~~~
./preloaded.h:8:13: note: candidate function not viable: no known conversion from 'std::vector<std::vector >' to 'const std::array<std::vector, 2>' for 2nd argument
std::string validateTwoSetsOfEqualSum(int n, const std::array<std::vector, 2>& answer) {
^
1 error generated.
As a suggestion, change the code to return the expected value as a
std::array<std::vector<int>, 2>
in conformance with your test function or change your test function to expect thestd::vector<std::vector<int>>
type.Upvote just for the cat.
I'm sure most people who clicked best practice or clever were clicking it because that's funny, they're the kind of answers that are like: if it works, then it works.
My intention was not to criticize you but, that is a really bad answer. An answer that I didn't ask for.
Even using other programming language, and the resulting code is by other programmers, the fact that people upvote to this is not good. Anyway, nothing can be done.
Because this make sanse for those who learn c++.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
If you really want to learn, try to be positive as when you receive the feedback about the people comments. Clearly this is not a good solution.
Not as simple nor readable as could be.
This comment is hidden because it contains spoiler information about the solution
Not a critique to the author of the solution but, I don't know why people marked this kind of solutions as best practices or clever if it uses a lot of functions and a data structure that make the algorithm waste computational resources.