Ad
  • Custom User Avatar

    This one was a time consuming kata.

  • 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

    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

    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,