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

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def xor(a,b):
	

Solutions:
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):
	return False if a and b else a or b


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):
	result = a ^ b
	return result


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


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):
	return a != b and max(a, b) == True


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):
	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


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


def xor(a, b):
	a = [a]
	b = [b]
	return sum(a + b) == 1


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


def xor(a, b):
	if a and b == True:
		return False
	elif a or b == True:
		return True
	else:
		False
	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):
	print((a, b))
	if a == True and b == False or (b == True and a == False):
		return True
	else:
		return False


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


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


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


xor = lambda x, y: x is not y


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):
	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:
		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 == b:
		return False
	print(a, b)
	return any([a, b])


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


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


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))


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):
	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]