Ad
  • Custom User Avatar

    Your code is not correct, it does not handle nested call correctly.

  • Custom User Avatar

    I seem to be running into the same problem. Have you ever been able to solve it?

  • Custom User Avatar

    This exercise has a good concept, but several aspects could be improved. First, the specification of function returns is unclear, which can lead to confusion, especially when dealing with recursive calls. Additionally, jump instructions and labels need more details, such as what to do if a label is undefined. There’s also a lack of proper validation for instruction parameters and error management. It would be helpful if the prompt provided more details on handling spaces, comments in the code, and how to properly concatenate values in the msg instruction.

  • Custom User Avatar
  • Custom User Avatar

    I don't think the solver should be in the position that they end up not knowing how their solution is called. "Your code should handle THIS" and then doesn't say what "THIS" is. That's weird, and something about that is an issue with codewars in general.

    But the issue tag comes with burden of proof and I didn't want that tag to be useful in debugging your code when replying within a few minutes.

    You are very likely printing multiple test cases.

  • Custom User Avatar

    I've found a way to work around it.

  • Custom User Avatar

    Then please tell me how I should print it. It'll be very helpful to me if I could get the actual input when trying to figure out where I went wrong. I might also be able to resolve the issue if it turns out I am doing it wrong.

    I could add that my current way of doing it is like this:

    foreach(string s in program)Console.Write("\"" + s + "\",");
    
    

    I use the extra characters(aside from the variable s) in order to copy it into vsc easier. But I'll throw in the result I get with the normal way of doing it:

    foreach(string s in program)Console.WriteLine(s);
    
    mov a 5
    inc a
    dec a
    dec a
    jnz a -1
    inc a
    mov a -10
    mov b a
    inc a
    dec b
    jnz a -2
    mov a 1
    mov b 1
    mov c 0
    mov d 26
    jnz c 2
    jnz 1 5
    mov c 7
    inc d
    dec c
    jnz c -2
    mov c a
    inc a
    dec b
    jnz b -2
    mov b c
    dec d
    jnz d -6
    mov c 18
    mov d 11
    inc a
    dec d
    jnz d -2
    dec c
    jnz c -5
    mov d 100
    dec d
    mov b d
    jnz b -2
    inc d
    mov a d
    jnz 5 10
    mov c a
    
  • Custom User Avatar

    you're probably reading your test output wrong and mixing up test cases. also the formatting in your post is messed up :x

  • Custom User Avatar

    why this fail,it expect -1 but it doesn't jump to exit function since both not equal

    mov i, 2 ; instruction mov i, 2
    mov q, 12 ; instruction mov q, 12
    call func
    msg 'Random result: ', n
    end

    func:
    cmp i, q
    je exit
    mov n, i
    sub n, q
    ret
    ; Do nothing
    exit:
    msg 'Do nothing'

  • Custom User Avatar

    I'm gonna go out on a limb and guess that whatever you're using to print the input is rather half-assed and that what you're showing ain't it.

  • Custom User Avatar

    I think there is an issue with the tests. Input:

    "mov a 5","inc a","dec a","dec a","jnz a -1","inc a","mov a -10","mov b a","inc a","dec b","jnz a -2","mov a 1","mov b 1","mov c 0","mov d 26","jnz c 2","jnz 1 5","mov c 7","inc d","dec c","jnz c -2","mov c a","inc a","dec b","jnz b -2","mov b c","dec d","jnz d -6","mov c 18","mov d 11","inc a","dec d","jnz d -2","dec c","jnz c -5","mov d 100","dec d","mov b d","jnz b -2","inc d","mov a d","jnz 5 10","mov c a"
    

    In here, there are 4 registers, a, b, c, and d.
    The test expects 3. c is left out. Going through it manually, it does seem like c is supposed to be processed on it's first occurrence "mov c 0"

    I recieve the error message

    Test Failed
      Expected: { d: 1, b: 0, a: 1 }, Actual: { d: 1, b: 0, a: 1, c: 0 }
    Assert.That(actual, Is.EqualTo(expected))
      Expected is <System.Collections.Generic.Dictionary`2[System.String,System.Int32]> with 3 elements, actual is <System.Collections.Generic.Dictionary`2[System.String,System.Int32]> with 4 elements
    
  • Custom User Avatar

    thanks. didn't see the double instructions until today. it would be better to follow the step by step style of the program and say:
    decrease by 1
    decrease by 1

    instead of "decrease its value by 2" which looks like an instruction call.

  • Custom User Avatar

    dec x should decrease the value in x by one. The example says "decrease by 2" because there are two dec a in a row in the example program.

  • Custom User Avatar

    ISSUE TYPO?:
    dec x - decreases the content of the register x by one
    =/=
    decrease its value by 2,

    should "dec" decrease by one or two?

  • Custom User Avatar

    Ok, just debugged for the last 1hour just to find out that when I remove my print Statements it works - since the max Buffer size was exeeded due to the log! ^^ LOL

  • Loading more items...