Ad
  • Custom User Avatar
    • jnz x y - jumps to an instruction y steps away (positive means forward, negative means backward, y can be a register or a constant), but only if x (a constant or a register) is not zero

    jnz 5 10 -> 5 here is a constant, which is not zero, which means your next step should be jumping forward 10 steps, which ends the program.

    Not a kata issue.

  • Custom User Avatar

    I believe this test case if wrong: { "mov d 100", "dec d", "mov b d", "jnz b -2", "inc d", "mov a d", "jnz 5 10", "mov c a" }
    When the code reaches the "jnz 5 10" no registers has the value 5.\

    Breakdown:
    mov d 100 -> d is 100
    dec 9 -> d is 99
    mov b d -> botb b and d are 99
    jnz b -2 -> we decrease the value of d then copy d's value to b until d is 0, so d and b is 0 when we reach the "inc d" instruction
    inc d -> d is 1 b is 0
    mov a d -> d and a are 1, b is 0
    jnz 5 10 -> no register has 5 as value

  • Custom User Avatar

    C# tests seem to be timing out on correct answer. Adding " " to output fails with only that as the error, but leaving it out times out every time.

  • Custom User Avatar

    the initial code tells you:

    register a goes into registers['a'], register b goes into registers['b'], etc.

    this is not what you are doing, you are putting a into registers[0], b into registers[1], etc

  • Custom User Avatar

    In C, when I print the registers[] array inside the function, the output matches the expected results exactly (at least when running the first test cases). Despite this, the tests still fail, showing that the registers are zero, not matching the expected output. What is the correct way to modify the array, so that the test framework correctly evaluates the results?

  • Custom User Avatar

    I believe there is a forever loop in one of the test cases. Specifically the case:

    [
    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,
    ]
    

    On line 7 reg b gets its initial value of -9 from reg a. On line 10 it is decremented to -10. It is then decremented 8 more times. When I get to line 24 reg b is -18 so it has me go back 2 where it has me decrement it again to -19. By the time it overflows the Int32 to get back to 0 it has timed out.

    Did I miss anything?

  • Custom User Avatar

    Thank you for answering. I have submitted my request.

  • Custom User Avatar

    You could save yourself the trouble by checking the list of available packages.

    Additional packages can be requested by creating a ticket in the Codewars runner repository.

  • Custom User Avatar

    I decided to learn Rust's Nom crate. Got a nice solution up and running with Nom, only to experience that Nom is not accepted. Nom has 158+ million downloads, and I will suggest that any rustacean would consider Nom for a task like this.

    Allow Rust Nom crate!

  • Custom User Avatar

    even better: just generate all 10000 digits first

  • Custom User Avatar

    Nice kata, too easy for 2kyu though

  • Custom User Avatar

    I don't understand neither: So if it's going out of range then selects the first (0) position again?

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    I have tested my program, and the complex_2 test says that the output should be {a=1, b=0, d=1}, and my output is {a=1, b=0, c=1, d=1}, and that is absolutely imposible, because if there's no letter c it wouldn't had added it to the map, so it has to be a letter c on the test. Which it would be nice to see what tests the program does, to prove them in the IDE and find errors.
    Sorry for my english, i'm not native and i don't know speak very well.

  • Loading more items...