# Exclusive "or" (xor) Logical Operator

## Overview

In some scripting languages like PHP, there exists a logical operator (e.g. ```&&```, ```||```, ```and```, ```or```, etc.) called the "Exclusive Or" (hence the name of this Kata).  The exclusive or evaluates two booleans.  It then returns true if **exactly one of the two expressions are true**, false otherwise.  For example:

## Task

Since we cannot define keywords in Javascript (well, at least I don't know how to do it), your task is to define a function ```xor(a, b)``` where a and b are the two expressions to be evaluated.  Your ```xor``` function should have the behaviour described above, returning true if **exactly one of the two expressions evaluate to true**, false otherwise.

Difficulty: introductory

Starter code:

def xor(a,b):
	

Solutions:
def xor(a,b):
    return a != b

def xor(a,b):
    return a ^ b

from operator import xor

def xor(a,b):
    return a is not b

def xor(a,b):
    print(a,b)
    if a == True and b == True:    
        return False
    elif a == True or b == True:
        return True
    return False

xor = int.__xor__

xor=lambda a,b: a!=b

xor = __import__("operator").__xor__

def xor(a,b):
    #your code here
    return False if a and b else a or b

def xor(a,b):
    return False if (a and b) == True or (a or b) == False else True

def xor(a,b):
    return len(set([a, b])) > 1

xor = lambda *_: _[0]^_[1]

xor = bool.__xor__

def xor(a,b):
    return bool((a + b) % 2)

def xor(a,b):
    if a == True and b == True:return False
    if a == True and b == False:return True
    if a == True and b == True:return True
    if a == False and b == False:return False
    else: return True

def xor(a,b):
    return abs(a-b)

def xor(a,b):
    if a == b:
        return False
    elif a != b or b != a:
        return True

def xor(a,b):
    truCount = 0
    if a:
        truCount += 1
    if b:
        truCount += 1
    if truCount == 1:
        return True
    return False

def xor(a,b):
    #your code here
    result = a ^ b
    return result

def xor(a,b):
    return True if (False in (a, b)) and (True in (a, b)) else False

def xor(a,b):
    if a==b:
        return False
    return True if a or b ==True else False

def xor(a,b):
    if a == b:
        return False
    elif a == True and b == False:
        return True
    elif a == False and b == True:
        return True
            
    #your code here


def xor(a,b):
    return (a+b)*((not a) + (not b))

def xor(a,b):
    if a==b==True or a==b==False:
        return False
    else:
        return True

def xor(a,b):
    if a == b == True:
        return False
    return True if a==True or b==True else False


def xor(a,b):
    c = 0
    n = str(a).count("True")
    m = str(b).count("True")
    c = n + m
    return (c%2)!=0

def xor(a,b):
    return (a==True or a==False) and a!=b

def xor(a,b):
    if a == b:
        return False
    if a == True or b == True:
        return True

def xor(a,b):
    return a != b and max(a,b) == True

def xor(a,
        b):

    return a != b


def xor(a,b):
    return a==True and b!=True or a==False and b!=False

def xor(a,b):
    if a is True and b is True:
        return False
    elif a is False and b is False:
        return False
    else:
        return True


def xor(a,b):
    return a or b if (a,b) != (True,True) else False

def xor(a: bool, b: bool) -> bool:
    return a ^ b

def xor(a,b):
    if a  is True and b is False or b is True and a is False:
            return True
    else:
        return False


def xor(a,b):
    count = 0
    if a == True:
        count += 1
    if b == True:
        count += 1
    if a != True:
        count -= 1
    if b != True:
        count -= 1
    if count == 0:
        return True
    return False

def xor(a,b):
    if a ^ b == False:
        return False
    elif b ^ b == False:
        return True

xor = lambda a, b: True if (not a and b) or (a and not b) else False

def xor(a,b):
    return b != a

def xor(a,b):
    return a is not b
    # by not it checks if a is not equal to b thus 'xor'


def xor(a,b):
    if a == False and b == False:
        return False
    if a and b == True:
        return False
    if a or b == False and a or b == True:
        return True

def xor(a,b):
    a =[a]
    b = [b]
    #if (sum(a+b) ==0) or (sum(a+b) == 2):
     #   return False
    #else:
     #   return True
    return (sum(a+b) ==1)

def xor(a,b):
    '''Function evaluates 2 expressions and returns true if only one of them is true'''
    if a is True and b is True:
        return False
    elif a is True or b is True:
        return True
    else:
        return False
    pass

def xor(a,b):
    if a==True and b==True:
        return False
    elif a==True and b==False:
        return True
    elif b==True and a==False:
        return True
    elif a==False and b==False:
        return False

def xor(a,b):
    if (a == True and b == False) or (a == False and b == True):
        return True #f'{a} xor {b} == True'
    else:
        return False #f'{a} xor {b} == False'

def xor(a,b):
    if a is b:
        return False
    else:
        return a or b

def xor(a,b):
    if a is True and b is False:
        return True
    elif b is True and a is False:
        return True
    else:
        return False

def xor(a,b):
    
    if a and b == True: return False
    if a or b == True: return True
    return False

def xor(a,b):
    #your code here
    if a and b == True:
        return False
    elif a or b == True:
        return True
    else:
        False
    return False


def xor(a,b):
    if a == False and b == True or b == False and a == True:
        return True
    else:
        return False

def xor(a,b):
    if not a:
        if b:
            return True
        else:
            return False
    elif not b:
        if a:
            return True
        else:
            return False
    else:
        return False

def xor(a,b):
    if a == True and b == True:
        return False
    if a == False and b == False:
        return False
    else:
        return True


def xor(a,b):
    if a == True and b == True:
        return False
    if a or b == True:
        return True
    else:
        return False

def xor(a,b):
    if a!=b:
        return True
    elif a==b:
        return False
    else:
        return False

def xor(a,b):
    print((a, b))
    if a == True and b == False or b == True and a == False:
        return True
    else:
        return False
    #your code here


def xor(a,b):
    return ((1-a)+(1-b))%2==1

xor = lambda a, b:False if a and b else True if a or b else False

def xor(a,b):
    j=False
    if(a!=b):
        j=True
    return j    
    #your code here


def xor(a,b):
    return False if a and b or a == False and b == False else True

def xor(a,b):
    if a is True:
        if b is True:
            return False
    if a is False:
        if b is False:
            return False
    if b is True:
        if a is True:
            return False
    if b is False:
        if a is False:
            return False
    if a is True:
        if b is False:
            return True
    if b is True:
        if a is False:
            return True

def xor(a,b):
    if a or b:
        if a and b:
            return False
        return True
    else:
        return False

def xor(a,b):
    if (a == True and b == True) :
        return False
    if a == True or b == True:
        return True
    return False


def xor(a,b):
    if int(a + b) == 0:
        return False
    elif int(a + b) == 1:
        return True
    elif int(a + b) == 2:
        return False

def xor(a,b):
    x = int(a)
    y = int(b)
    return a^b


def xor(a,b):
    if a == False and  b == False:
        return False
    elif a == True and b == True:
        return not a
    return a or b

def xor(a,b):
    if a==True and b==True:
        return False
    elif a==True and b==False:
        return True
    elif a==False and b==False:
        return False
    else:
        return True

def xor(a,b):
    return (a,b) == (True,False) or (a,b) == (False, True)

xor = lambda x, y: x is not y

def xor(a,b):
    if a == True:
        if b == True:
            return False
        else:
            return True
    elif b == True:
        if a == True:
            return False
        else:
            return True
    else:
        return False

def xor(a,b):
  if a and b == True:
    return False
  else:
    return a or b


def xor(a,b):
    return (a is b) is False

def xor(a,b):
    return not (not (a or b) or (a and b))

def xor(a,b):
    if a == True and b == True:
        return False
    elif (a == True and b == False) or (a == False and b == True):
        return True
    else:
        return False

def xor(a,b):
    my_bool = True
    if a and b:
        return False
    elif a == False and b == False:
        return False
    elif a or b:
        return True
    


def xor(a,b):
    
    if a == True and b == False:
        return True 
    elif a == False and b == False:
        return False 
    elif a == False and b == True:
        return True
    elif a == True and b == True:
        return False

def xor(a,b):
    if a:
        if b:
            return False
    return a or b

def xor(a,b):
    if a is not b:
        return True
    else:
        return False

def xor(a,b):
    if(a == False and b == False):
        return False
    if(a == True and b == True):
        return False
    if(a == False and b == True):
        return True
    if(a == True and b == False):
        return True

# end goal - function should return True if exactly ONE of two expressions evalualte to true, otherwise false
# input = two booleans, a and b
# output = boolean

# How would the computer recognize that only one boolean is True when nested? by comparing the two booleans rather than conditionals for each statement

#function xor taking two expressions a, b
def xor(a,b):
# if a is not equal to b, then only one of the expressions can be True
    return a != b


def xor(a,b):
    if a is False and b is True:
        return True
    elif a is True and b is False:
        return True
    else:
        return False

def xor(a,b):
    if a == b:
        return False
    print(a,b)
    return any([a,b])

def xor(a,b):
    if a == True:
        if b == True:
            return False
    if a == True:
        if b == False:
            return True
    if a == False:
        if b == False:
            return False
    if a == False:
        if b == True:
            return True

def xor(a,b):
    #your code here
    # checking the a and b values for false - false respectively 
    if not a and not b:
        return False
    # checking the a and b values for true - false
    elif a and not b:
        return True
    # checking the a and b values for false - true
    elif not a and b:
        return True
    # checking the a and b values for true - true respectively 
    else:
        return False

def xor(a,b):
    xor = False
    if a == True and b == True:
        xor = False
    elif a == False and b == False:
        xor = False
    elif a == True and b == False:
        xor = True
    elif a == False and b == True:
        xor = True
    return xor

def xor(a,b):
    return (a+b < 2) and (a+b > 0)

def xor(a,b):
    answer = 0
    if a == True:
        answer += 1
    if b == True:
        answer += 1
    if answer == 1:
        return True
    else:
        return False
        


def xor(a,b):
    if a == True and b == True:
        return False
    elif a == False and b == False:
        return False
    elif a == False and b == True:
        return True
    elif a == True and b == False:
        return True
    else:
        return False

xor = lambda a,b: int(a) ^ int(b)

def xor(a,b):
    if a is True and b is True:
        return False
    if a is True and b is False:
        return True
    if a is False and b is True:
        return True
    if a is False and b is False:
        return False

xor = lambda a, b : int(a) + int(b) == 1

from operator import xor as xor_
from functools import reduce

def xor(a,b):
    return reduce(xor_, (a, b))

def xor(a,b):
    if a == False:
        if b == True:
            return True
        elif b == False:
            return False
    if a == True:
        if b == True:
            return False
        elif b == False:
            return True

xor = lambda a,b: a+b == 1

def xor(a,b):
    c = 0
    if a:
        c += 1
    if b:
        c += 1
    if c == 1:
        return True
    else:
        return False


from operator import xor as xor1
def xor(a,b):
    return xor1(a,b)

def xor(a,b):
    return False if a==b else True
    
#returning False when a equals to b else its returning true


def xor(a,b):

   result = True
   
   if a==True and b==True:
      result=False
   elif (a == True and b == False) or   (b == True and a ==False):
      result=True
   elif a==False and b==False:
      result=False 
      
   return result   

def xor(a,b):
    print(a,b)
    if a == True and b == False:
        result = True
    elif a == False and b == True:
        result = True
    else:
        result = False
    return result

def xor(a,b):
    return (False, True) [a != b]