Ad
  • Default User Avatar

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

  • 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!

  • 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.

  • 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.