Ad
  • Default User Avatar

    instead of using constexpr you can use the char value, for example if(tempInt >= 'A') will be the same as if(tempInt >= 65)

  • Default User Avatar

    identical except for the leading '0's handling.
    disappointing

  • Default User Avatar

    so long
    too much repetitive code.
    try fix it

  • Custom User Avatar

    I agree, the description is really problematic... after too much time I learned that:

    1. You need to convert the input to bits and the result of that conversion is used as the source for the "tape" building
    2. The "tape" is being built by the following commands: [',', '<', '>'] (I wrote it as array for easy understanding)
    3. The '+' command is flipping the value which the pointer point at at the "tape"
    4. The ';' command is adding a 0 or 1 to the binary output build according to the value being pointed by the pointer at the "tape"
    5. '[' and ']' are changing code positions

    I hope this help!

  • Default User Avatar

    The kata is great imo, but is seems pretty similar to this one (please correct me if i'm wrong!).

  • Default User Avatar

    I'm a little confused as to the description of the +'s character function. Does flipping the bit under the pointer refer to the bit in the input itself? I guess my confusion comes from the fact that the usage of , is described as such : "Reads a bit from the input stream, storing it under the pointer.", where storing would imply the value is isolated from the input. Please correct me if my understanding is wrong.

  • Default User Avatar

    Indeed, my code was buggy (didn't think of different function calls) : sorry for marking as an issue, and thanks for the help!

  • Custom User Avatar

    Your solution indeed contains a bug. To identify it, you need to run two test cases locally, in a way that your implementation of add is invoked twice. For example, you could try

    int main() {
    
       cout << add("0", "0") << endl;
       cout << add("99", "2") << endl;
    
       return 0;
    }
    

    and observe how every invocation except the first one returns invalid result.

  • Default User Avatar

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

  • Custom User Avatar

    You can post your code (or link to it) here (remember about markup formatting and spoiler flag) and someone will hopefully take a look and share some advice.

  • Default User Avatar

    I wrote my code in VStudio and copy/pasted it in the kata once I thought it worked correctly. When the random tests came up, the output of my code was apparently wrong. So I outputted the initial strings (numbers) used in these random tests (using cout), and tried them in VStudio. The outputted number was not the same on my local machine : it was what was supposed to be correct. Could the problem be in the compiler? I don't use any standard lib functions, only char casting and several for loops... (I can upload the code if necesseray)

  • Custom User Avatar

    Python 3.x should be enabled.

  • Default User Avatar

    Retried it several times and it ended up working...

  • Default User Avatar

    My code (C++) passes the sample tests, yet, when I attempt the whole kata, it says the BasicTests are passed, but exits with code 132 (without even attempting any random test or something else).

    SampleTests : Time: 1849ms Passed: 1 Failed: 0

    Test Results: ExampleTests (green arrow); BasicTests (green arrow);

    Kata Attempt: Time: 2146ms Passed: 1 Failed: 0 Exit Code: 132

    Test Results: ExampleTests (RED arrow); BasicTests (green arrow);