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.
Unfortunately, I caved in and looked at the solutions for this one.
I was thinking it correctly, but putting it wrongly into code.
Anyway, your advices are good to keep in mind so that I can write clearer and cleaner code.
Thank you for your feedback :)
I think it would be very helpful if you first polished this code with the following:
Closing the question, it seems you finally solved it.
Again, the problem is in your if condition, not with negative numbers.
Thank you all!! I was thinking this too far and missed this obvious and simple way to check the input.
It seems that my code is not doing well with negative numbers.
I'll try to fix it.
Thanks again!
I don't really know the best ways for C++, but with the given C++ template you can do something simple, like:
@Chrono79, I've put a break in my if condition so that it stops searching once the element was found.
So now {1,5,7} => 3 works on my IDE, but here it is still not compiling.
@B1ts, I don't know how to print the test cases... how do I write things after std::cout?
I haven't done anything similar to this until now.
All the test cases given by Chrono79 pass in VS.
Don't print stuff in tests suite, print it in your function. For C++ you should know about
std::cout
.Well, now you see your code isn't right, so fix it. I've already told you where to look.
Well, with this one it returns 7 ...
@hobovsky, the link you gave me is not very helpfull for me. I only know C++ and I didn't found on that page how to print tests in C++.
The test at the bottom of the page looks like below. I have no idea how to print something like this..
Describe(Tests)
{
It(Random__Tests)
{
dotest(10,0);
dotest(10,10);
dotest(10,100) ;
dotest(10,1000) ;
}
};
And with this one?
Don't just make up inputs, test with them, and call it a day. Check the actual inputs, and test these in your VS.
Yes, and it returns 5.
I have also tested it with {4, 8, 16} and it returned 12 :(.
No idea, are you testing it there with the same input values that are used here?
Your if condition seems to be true for all the elements of the serie.
This comment is hidden because it contains spoiler information about the solution
Loading more items...