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.
In order to solve this kata one cannot use brute force logic. Meaning you cannot just try all possible sums of consecutive integers and check if they are equal to N. It's much better to step back and find a general pattern for all N that are true.
What do all N that are true have in common?
(Technically in the real world brute force is a (very poor) solution that (kinda) works, but it timing out here in this kata is a good thing. It makes you find a more elegant and faster solution.)
See my solution with added comments if you cannot figure it out. I am aware that there are more elegant solutions out there, but I think my solution will explain why it works in an easy to understand way. Please comment if you disagree and have a better way to explain it. (I love being wrong and to learn new things).
why are you using floor specifically?
floor in C++
What does the function floor do?
(Using C++) had the same, my issue was the use of sizeof(inputStr) to get the lenght of the string. sizeof() only returns a maximal count of 32, if a string was longer thant 32 characters the test cases would fail. I then switched to inputStr.length() which ended up working fine. Hope that helps.