Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    The description states that the condition for performing changes to the array is

    if X[i] > X[j] then X[i] = X[i] - X[j]

    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.

  • Custom User Avatar

    Now the question would be: why did it work on your machine?

  • Default User Avatar

    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.

  • Custom User Avatar

    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.

  • Default User Avatar

    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.

  • Default User Avatar

    Hi, the function signature is:

                                             vvv
    func Mixbonacci(pattern []string, length int) []int64
    

    not

                                             vvvvv
    func Mixbonacci(pattern []string, length int64) []int64
    

    Regards,

    suic

  • Default User Avatar

    Hi, paste here your solution as Go code block and mark you comment as spoiler. Regards, suic

  • Default User Avatar

    The tests are alright. Check your code.

  • Custom User Avatar

    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

  • Default User Avatar

    Can anyine help me?

    It's a question, not an issue. You should read https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution.

  • Custom User Avatar

    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