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.
This comment is hidden because it contains spoiler information about the solution
Update: I was wrong, the tester works. After working on a similar problem, I finally understood what was happening and modified my code accordingly. It now works will all the tests and I finally got credit.
Thank you to Unnamed and Chrono79 for your patience and understanding ( and the gentle hints that you gave).
All I will say here is that in the C++ version, you have to really understand your data types.
Solution will be posted in the next reply (as Spoiler).
This comment is hidden because it contains spoiler information about the solution
EDIT: ignore this post; I replied incorrectly.
Per request for clarification, as of today the Author has thoughtfully corrected the instructions to indicate this Problem only includes positive values.
UPDATE: Both issues have been resolved! I was wrong, the tester is working properly, it was my code that faulty. I have left comments below on subsequent comments that explain why. Explanation & Code samples from both my successful and unsucessful attempts are in subsequent replies marked as spoilers. Thank you to Unnamed & Chrono79!
Instructions: Thank you for updating the instructions in regards to the input, it looks good!
Overflow Issue: I will try again using some different methods. I will report progress later to this thread.
If unsuccessful, I will report my code on seperate reply and mark as spoiler to avoid giving away answer.
(Note, this was done, see subsequent replies, however I found out my code was faulty. Explanations and fixes are below.)
C++ (14) Version - There appears to be an overflow issue. Maybe the datatypes in the tester need to be improved to handle larger numbers ( long long ? ) The final tests are failing on 'ExtendedTest3'(passing all the previous sample + all other previous final tests), the Actual result is a negative number '-294967296'
The function returns "Expected: equal to 4000000000 Actual: -294967296", which should be impossible since I'm simply adding the smallest two elements in the range (and the array given contains NO negative numbers. I've tried experimenting with changing the function type to 'long', 'long long int', 'unsigned long long int', etc. with no success (even tried an intermediary 'long long int' variable to store the sum before returning it.). I've also tried changing the parameter type from '' to '' without success. I keep getting a failure on the ExtendedTest3 with my actual result being a negative number.
Positive Numbers -> The instructions are vague on the array (or vector if in C++ version) of the "sum of the two lowest positive numbers given an array of minimum 4 integers". Are we to assume that all the numbers that we have been given are positive?
If YES, that should be more explicitly definied in the instructions, especially for a low difficulty 7 kyu problem. Language like "You may assume that all values of the array are positive".
If NO, then the Sample Tests should include negative numbers for completeness along with the final tests. Also, instructions should be updated to say "There will be at least two positive values within the array" (with test cases that match this language).