Sort by

recency

|

94 Discussions

|

  • + 0 comments

    You will have to read through the questions thoroughly, which clearly states 3 lines mods... Here are my C++ changes to fix the issue

    for (int i = 0; i < s.size(); i++)
    {
      if ((s[i] == t[i]) && ((s[i] == '0') || (s[i] == '1'))) //1st change
         res += '0';   //2nd change
        else
          res += '1';   //3rd change
    }
    
  • + 0 comments

    something does seem to be wrong with the "grader" for both supported C++ versions. Take a look at the results, after I made the [3 quick-and-simple] fixes…

    Compiler Message

    Wrong Answer

    Input (stdin)

    10101
    
    00101
    

    Your Output (stdout)

    10000
    

    Expected Output

    10000
    
  • + 0 comments

    Many languages where there is no code should be hidden... if that a thing. And something's wrong with C++ grader?

  • + 0 comments

    The C code is almost blank, just the main function and not the strings_xor function. So i had to create the code by myself so of course it doesn't work since the main condition isn't satisfied (just 3 lines)...

    C implementation :

    #include <math.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <assert.h>
    #include <limits.h>
    #include <stdbool.h>
    
    char * strings_xor(char * input1, char * input2)
    {
        char * answer = malloc(strlen(input1) * sizeof(char));
        
        for (int i = 0; i < strlen(answer); ++i)
        {
            answer[i] = '0';
        }
        
        // We read the console
        
        scanf("%s\n",input1);
        scanf("%s\n",input2);
        
        // We calculate the XOR relation between the inputs
        
        for (int i = 0; i < strlen(input1); ++i)
        {
            if (input1[i] != input2[i])
            {
                answer[i] = '1';
            }
            if (input1[i] == input2[i])
            {
                answer[i] = '0';
            }
        }
        
        return answer;
    }
    
    int main()
    {
        // We create three pow(10,4)+1 length string variables to stock the inputs and to create the answer
        
        char * input1 = malloc((pow(10,4)+1) * sizeof(char));
        char * input2 = malloc((pow(10,4)+1) * sizeof(char));
        
        char * answer = strings_xor(input1,input2);
        
        // We display the answer
        
        printf("%s",answer);
        
        free(input1);
        free(input2);
        free(answer);
    	`
        
        return 0;
    }
    
  • + 1 comment

    C# implementation:

    static string strings_xor(string s, string t)
    {
        string result = "";
    
        for(int i = 0; i < s.Length; i++)
        {
    
            result += s[i] == t[i] ? '0' : '1';
        }
    
        return result;
    }
    

    Compiler is saying "Wrong Answer".