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
The description states that the condition for performing changes to the array is
for any i, j pair.
12 > 12
is false, so no changes are made to the array, which is then summed: 12 + 12 = 24 as expected.can you please explain how does it work?
cause I'm an idiot, I confused "Expected" with "to equal"
Now the question would be: why did it work on your machine?
Yeah, thats it! Thank you so much!
That testcase looks familiar: I think the inner loop executes over 300,000 times.
I agree with hobovsky's interpretation. In Go, accessing a map evaluates to 0 for missing elements. For the source code of "jnz 1 5", case "jnz" performs a lookup res["1"] which doesn't match any named registers. That evaluates to zero, and causes "jnz 1 5" to do nothing. The expected behavior is to jump +5 instructions.
I do not speak GO, so I am not able to verify your solution in details, but for what it's worth, for this input my Python solution returned what tests consider correct, so test seems to be OK.
Regarding your solution, I think it does not handle well instruction
jnz
where jump condition operand is given as immediate value, for example such one:"jnz 1 5"
. I think it considers only registers as the first operand, am I right?EDIT: FYI I fixed handling of
jnz
instruction in your solution and it passes for me.This comment is hidden because it contains spoiler information about the solution
Did you see the part about "Debug your solution"? There is a link to another document that starts with:
"Most (all?) languages on CodeWars support writing to standard output. You can use stdout functions of your language to print function arguments (or anything else) and it will be visible in test output panel."
It's harder to debug if you don't reveal which input caused your test to fail, plus the expected output and what your code actually produced.
oh man... i had to forfeit, because i had no idea how to improve the solution, and how to find mistake sinse exact same code works fine on my machine (yes, i've read https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution#my-machine)... I now I can see that right solutions are same in principle with my, so i dont now what to think, I really need help on this one so I wouldnt repeat this mistake!
that works, thanks!
Hi, the function signature is:
not
Regards,
suic
This comment is hidden because it contains spoiler information about the solution
hm, my solution (pretty straight up) work fine on all test exept one, which gets wrong answer, so its not about time. But on my machine same code returns right answer. how is it possible?
Loading more items...