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

    I like how you combined both the encode and decode into one method. Very clean. Nicely done!

  • Custom User Avatar

    Something is wrong. When I run my solution in Visual Studio it takes 12,000 ticks. 1 millisecond = 1000 ticks. Why does it take more than 12,000 milliseconds (12,000,000 ticks) to run the same code here? I believe I have a solution but it times out. This is frustrating.