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.
nice :)))
This comment is hidden because it contains spoiler information about the solution
Unfortunately, in C and C++ things are not that easy.
Invalid memory access is defined in C++ as a cause of undefined behaior, and this can mean anything. In your case, your solution writes outside of the result buffer and modifies something which is later on used to calculate reference solution, or to print the message, or anything else. When undefined behavior happens, there are no guarantees anymore: anything can change, anything can break, even things apparently unrelated.
If I were to guess,
sprintf
puts null terminator right behind your buffer, and probablyg
variable happens to be located there on the stack, messing up further computations. But it's just guessing, and it can be wrong or can change from run to run.I'm not claiming my code is perfect by any means - I'm here to learn after all.
But my terrible code shouldn't change the expected values? The first print in my first screenshot was the first line in the function
the expected values are still 0, which is what my original issue was for
From all the things which are wrong with your solution, the wrongest ones are probably buffer overflow and missing includes.
This comment is hidden because it contains spoiler information about the solution
Seeing your code would help too.
Oh, Perhaps i'm missing something then.
The basic tests work fine, but none of the random ones do. I put some logs in to the code - as you can see here https://imgur.com/a/quZ5I95
Every random test results the same thing, my debugs display a (seemingly correct?) logical progression to a non-0 Hex value, but then the expected value always has the green value as 00.
C++ tests seem to be fine.
C++ Does not work, Basic tests are fine, but all random tests expect values as if green was 0.