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 :)
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!
@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.
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) ;
}
};
Yes, and it returns 5.
I have also tested it with {4, 8, 16} and it returned 12 :(.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Thank you so, so much for your help.
I modified the loops and passed all the tests with flying colours :)
Then something is off with the test case I think. The last assert has index 0 and 1 with equal values. And it states that it should pass.
It(should_pass_some_fixed_tests)
{
Assert::That(two_sum({1, 2, 3}, 4), Fulfills(EqualsUnordered{0, 2}));
Assert::That(two_sum({1234, 5678, 9012}, 14690), Fulfills(EqualsUnordered{1, 2}));
Assert::That(two_sum({2, 2, 3}, 4), Fulfills(EqualsUnordered{0, 1}));
K. I've reposted my question.
Thanks.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution