Ad
  • 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

    First off I'd like to say that this is a really fun kata, thank you! I believe there is an error with the test conditions on the Lua version of this kata though. The basic test is checking my answer against {a = 1, b = 0, d = 1} when my answer is {a = 1, b = 0, c = 0, d = 1}. The only way that the 'c' register can be omitted from the answer is if it is never initialized in the program, but following the assemply closely it is clearly initialized very early on in the code. Due to this discrepancy I am unable to finish this kata. If I am misunderstanding please let me know. Thank you!

  • Custom User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    The description contains incomplete information about the task; very important information is missing:

    1. Differences between calling and jumping/how ret works are not clearly described
    2. It is not described that code can move from line to line between functions ( for example, based on Blind4Basics hints https://www.codewars.com/kata/58e61f3d8ff24f774400002c/discuss/python#5c35e71101883f5597eb533d )
  • Custom User Avatar

    Is it normal for the C++ "Complex 1" test to be so long? It seems to make nested loops with so many iterations that my program ends up in a timeout. The program is {"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" }.

    When I test it with a lower value of d for the 4th instruction, the program manages to finish before timing out. For example, with mov d 13, I get [ ("c", 0), ("b", 377), ("d", 0), ("a", 808) ] as a return.

    EDIT: Nevermind, for some reason now it works... I guess the servers were a bit too busy at some point.

  • Custom User Avatar

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

  • Custom User Avatar

    Could it be updated to a more recent Node version?

    I have finished this on my machine, but I am unable to pass the tests because a bunch of functions and language features are missing.

    Things such as:

    • Named capture groups (/(?<number>\d+)/)
    • String.prototype.at
    • String.prototype.matchAll

    Nevertheless, it was fun to complete!

  • Custom User Avatar

    Kotlin version:

    My solution passed all the tests but the "Complex2" one: it throws a NoSuchElementException for ListIterator.previous and ListIterator.next. Moreover, for some of the tests, additional functions (so the "interpret" one is excluded) are not visible.

  • Default User Avatar

    C:

    • the return value in case of error ((char *)-1) is nonsensical, very bad practice and undocumented;
    • memory allocation of the returned pointer is not documented;
    • tests suite crashes when the expected value is (char *)-1 and the actual value is not;
  • Custom User Avatar

    Language C:

    Looking for some hints for the actual test cases. I'm able to pass all example cases and one of the random ones. However, I keep getting stuck with a SEGFAULT Invalid Memory Access. Obviously I cannot print out the test case during a SEGFAULT, but I'm trying to think of edge cases where my program could SEFAULT. I can't think of weird inputs that would cause an invalid memory access. Are there any "gotcha's" in the submission cases that I'm missing?

  • Default User Avatar

    My solution uses kotlin.

    For the test part it works. But on attempt, always fails on random and complex.

    An example of the random test results:
    expected:<{w=17, q=-29, a=5, d=-6, z=-7, f=6, l=71, n=75, o=0, r=0, c=-47, u=0, e=-7, x=0, k=33, t=71, b=0, s=0, h=8, j=17, y=2, i=-2, v=-6, g=9, p=6, m=100}> but was:<{w=17, q=-29, a=5, d=-6, z=-7, f=7, l=71, n=75, o=0, r=0, c=-47, u=0, e=-7, x=0, k=33, t=71, b=0, s=0, h=8, j=17, y=2, i=-2, v=-6, g=12, p=6, m=100}>
    I can't understand. Is there a way to get random and complex instruction to evaluate?

  • Default User Avatar

    I really don`t understand the explanation. it says:

    "inc x - increases the content of the register x by one

    dec x - decreases the content of the register x by one

    jnz x y - jumps to an instruction y steps away (positive means"

    ["mov a 5"; "inc a"; "dec a"; "dec a"; "jnz a -1"; "inc a"]

    visualized:

    The explanation says (I put results inside parenthesis based on the instructions):
    The above code will:

    • set register a to 5,
    • increase its value by 1 (now "a" is 6),
    • decrease its value by 2 (now "a" is 4),
    • then decrease its value until it is zero (jnz a -1 jumps to the previous instruction if a is not zero) - (now "a" is 3 because it jumps to previous "dec" instruction)
    • and then increase its value by 1, leaving register a at 1 - (now "a" is 4)


      So, the function should return: Map("a"->1)

    Why map will be 1 instead of 4?

    In my understanding its impossible,

  • Custom User Avatar

    I think the kata description should've mentioned that labels/coroutines themselves can be "run over" and the program should just ignore them. I've spent a lot of unnecessary time trying to wrap my head around that recursive power function due to this (@Blind4Basics and @AnitaK comments helped a lot, but all necessary information should be available in the kata description or tests).

    Also, even though it's not tested, I think the kata's description should mention that indentation has no particular meaning, since that implies labels/coroutines can be nested.

  • Custom User Avatar

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

  • Loading more items...