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.
Math.sign(size % 4)
will return '0' ifsize
is a multiple of 4 and '1' if it is not.For the case if
size
is a multiple of 4, I just want to invert1
and0
in array one time less (see the picture prior to the solution - sust the case: 3 elements to be inverted).- 1 + Math.sign(size % 4)
Hereby, this will give -1 to size/2 if the
size
is a multiple of 4 and nothing (-1 + 1) if not.// How can I explain this idea? I cannot. I remember that I just drew some variants on paper and came to this idea empirically...
Fixed.
So, the problem with invalid chars existing in the test data still persists. I've tried a number of ways to get past this and it looks like it's on the test side and not mine. To give you an idea, at one point I was able to pass one of the real world tests by appending 3 nulls to the end of the string, which matches what I found in the infix passed to me. The next test failed with nulls mixed in at other positions.
This is really frustrating. I've spent more time debugging problems with the test code than with my own.
This usually indicates a segfault (with C++ on CW). I printed the ascii of the input, and there are null characters (ASCII 0) in the input for the "real" test cases. I added an if to ignore these and any non-digit/non-operator/non-parenthesis, but I'm still getting a segfault (I guess), too.
You have received this error?
If yes, I've got the same problem.
// solution: virtual void POSTFIX::TESTS(): Assertion `to_postfix(infix) == postfix' failed.