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.
Thanks a lot. I now understand what the issue was and the code works here as well.
Is there a way to debug the code here by stepping through all instructions? That's how I debugged it in Visual Studio
prints out 0
or just nothing when not casting it to an int
my problem is that it is only incorrect in the codewars compiler. The output I get from
spinWords("Welcome")
in my "test" in themain()
function in my code is right:Output in godbolt:
the word "Welcome" has more than 4 letters hence it's reversed.
Now another test:
and the output:
as you can see my algorithm is not the problem. It works everywhere but codewars.
Hi again, sorry for the late reply to my own question, but the main function was only for the code to compile on godbolt and I removed it whenever testing it on codewars. In main() I just cout'ed the output from my spinWords to show that the algorithm works. The test has the same input as in cout in the main() function. In main(), my function outputs the same as the expected output from the test but fails the test when compiled on codewars.
This comment is hidden because it contains spoiler information about the solution
I coded (C++) the algorithm in visual studio, everything works. I copied the code in here and suddenly it's broken. Compiles and works on godbolt and same compiler. Any ideas?