Ad
  • Custom User Avatar

    I don't think the solver should be in the position that they end up not knowing how their solution is called. "Your code should handle THIS" and then doesn't say what "THIS" is. That's weird, and something about that is an issue with codewars in general.

    But the issue tag comes with burden of proof and I didn't want that tag to be useful in debugging your code when replying within a few minutes.

    You are very likely printing multiple test cases.

  • Custom User Avatar

    I've found a way to work around it.

  • Custom User Avatar

    Then please tell me how I should print it. It'll be very helpful to me if I could get the actual input when trying to figure out where I went wrong. I might also be able to resolve the issue if it turns out I am doing it wrong.

    I could add that my current way of doing it is like this:

    foreach(string s in program)Console.Write("\"" + s + "\",");
    
    

    I use the extra characters(aside from the variable s) in order to copy it into vsc easier. But I'll throw in the result I get with the normal way of doing it:

    foreach(string s in program)Console.WriteLine(s);
    
    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
    mov d 100
    dec d
    mov b d
    jnz b -2
    inc d
    mov a d
    jnz 5 10
    mov c a
    
  • Custom User Avatar

    I'm gonna go out on a limb and guess that whatever you're using to print the input is rather half-assed and that what you're showing ain't it.

  • Custom User Avatar

    I think there is an issue with the tests. Input:

    "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","mov d 100","dec d","mov b d","jnz b -2","inc d","mov a d","jnz 5 10","mov c a"
    

    In here, there are 4 registers, a, b, c, and d.
    The test expects 3. c is left out. Going through it manually, it does seem like c is supposed to be processed on it's first occurrence "mov c 0"

    I recieve the error message

    Test Failed
      Expected: { d: 1, b: 0, a: 1 }, Actual: { d: 1, b: 0, a: 1, c: 0 }
    Assert.That(actual, Is.EqualTo(expected))
      Expected is <System.Collections.Generic.Dictionary`2[System.String,System.Int32]> with 3 elements, actual is <System.Collections.Generic.Dictionary`2[System.String,System.Int32]> with 4 elements
    
  • Custom User Avatar

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

  • Custom User Avatar

    The windows ansi (e.g) encoding for "¤" is 164 but the UTF8-Encoding for "¤" is: {194, 164} or in Trinary {"21012", "20002"}. The question mark means there is no valid UTF8 encoding given.
    As you can see in https://en.wikipedia.org/wiki/UTF-8 under the heading "Code point UTF-8 conversion" there are 2 bytes required for the character "¤" resp. &currenc resp. Ansi1252 = 164
    The assert should be

     Assert.That(source.FromTrinary("010210 010220 010221 010202 010222 010211 010221 010222 010222 010222 021012 020002 001101 001022 001020"), Is.EqualTo("fijekgjkkk¤%#!"));
    

    Please note the inserted 021012.

  • Custom User Avatar

    Hi!

    Sorry I'm slow to answer, been away for a while.

    The space was originally left in there intentionally, but I forgot to remove it when I decided to only have correct test inputs. I'll fix that right away.

    An emoji test would be fun, but I'd have to adjust my current solution before I do that!

    As for your solution, I'm not quite sure where it goes wrong. The decimal for ? is 63, the trinary would be 002100. The decimal for ¤ is 164, the trinary would be 020002. I can't see why your code confuse these two. I would suggest testing the code with different inputs and see where things stop working.

  • Custom User Avatar

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

  • Custom User Avatar

    Thanks! I didn't even think about that part. Forgive me, it's my first kata! I have fixed it now.

  • Custom User Avatar

    The first point means that when I want to solve your kata and open the kata trainer view, there is already some code for some unrelated problem (it is an example of C# kata. it is meant as help for authors, and should not be a part of a published kata).

  • Custom User Avatar

    I'm not quite sure what you mean by the first point, but I could make some random tests.

  • Custom User Avatar
    • Solution Set-Up contains code for some other kata (I have tried resetting)
    • no Random Tests
  • Custom User Avatar

    The first thing I thought was "Really? This simple?" Then I realized why we were to use BigIntegers.
    It was a nice way to force me into learning more about kotlin's long variable!

  • Custom User Avatar

    I checked out the C# version. All the random test have an array with 10 ints. Kotlin varies with up to 100k per test. I can sometimes get through 10+ random tests within the 16000ms, but other times I just go through 2. At this point, I can just click 500 times on attempt and hope to god all the random tests give me <10000 ints in the array. This is ridiculous.

  • Loading more items...