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.Now the question would be: why did it work on your machine?
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.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.
Hi, the function signature is:
not
Regards,
suic
Hi, paste here your solution as Go code block and mark you comment as spoiler. Regards, suic
The tests are alright. Check your code.
More interesting thing is what you use for "making large string of all squares"? This part often trips newbies up, because often they do not know why the most obvious way is wrong.
https://stackoverflow.com/questions/1760757/how-to-efficiently-concatenate-strings-in-go
It's a question, not an issue. You should read https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution.
11k people solved this already, that's not an issue. How should I fix your code, if you didn't post it.
Use three
`
and[your language] [your code]
and again three`
to show your code and mark it as spoiler so I can help you