Sort by

recency

|

92 Discussions

|

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

  • + 0 comments

    include

    using namespace std;

    string strings_xor(string s, string t) {

    string res = "";
    for(int i = 0; i < s.length(); i++) {
        if(s[i] == t[i])
            res.push_back('0');
        else
            res.push_back('1');
    }
    return res;
    

    }

    int main() { string s, t; cin >> s >> t; cout << strings_xor(s, t) << endl; return 0; } ** still the compiler is saying "Wrong Answer"

    the

  • + 1 comment

    Here is my Python solution!

    def strings_xor(s, t):
        res = ""
        for i in range(len(s)):
            if s[i] == t[i]:
                res += '0'
            else:
                res += '1'
    
        return res
    
    s = input()
    t = input()
    print(strings_xor(s, t))