Ad
  • Custom User Avatar

    This is due to Kotlin version is stuck at 1.3 at the time of writing this solution. However, 1.9 has been enabled now and the above warning should not happen again.

  • Custom User Avatar

    This one was a time consuming kata.

  • Custom User Avatar

    See the keypad image in the description, adjacent to 9, there is only 6 and 8.

  • Custom User Avatar

    I'm based on provided test cases in the Kotlin language.
    "Is the test that you are referring to the one with input = '369' ? "

    That's correct.

    "Then '333' isn't valid because the last '3' in '333' is not adjacent to the '9' in '369'."

    I don't get it. How so 'last 3' is not adjacent? I believe I missing some concept.

  • Custom User Avatar

    As there are different languages available, it's best if you actually type out specifically which test input you are having a question about (for ex the "third" test on Python is with the digit '0' so obviously not the one you are talking about).

    Is the test that you are referring to the one with input = '369' ? Then '333' isn't valid because the last '3' in '333' is not adjacent to the '9' in '369'.

  • Custom User Avatar

    I'm confused. Why in the second case 11 is one of the valid numbers but 333 isn't a valid number on the third?

  • Custom User Avatar

    I did with kotlin. I always code my solutions on kotlin play ground. My solution uses Duration class.

    Here in code wars it complains because its experimental.

    I'm addressing this to the moderator of kotlin to fix this.

    The error is:


    error: this declaration is experimental and its usage must be marked with '@kotlin.time.ExperimentalTime' or '@OptIn(kotlin.time.ExperimentalTime::class)

  • Custom 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?

  • Custom User Avatar
  • Custom User Avatar

    after you jump back to the previous dec a, you move forward to jnz, which is effectively a loop until a is 0. Then you ignore the jump and move to the next instruction, which increases a (now 0) to 1.

  • Custom 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,