Introduction to Disjunctions
In logic and mathematics, a disjunction is an operation on 2 or more propositions.  A disjunction is true if and only if 1 or more of its operands is true.  In programming, we typically denote a disjunction using "||", but in logic we typically use "v".
Example of disjunction:
p = 1 > 2 = false
q = 2 < 3 = true
therefore p v q is true
In a programming language, we might write this as:
var p = 1 > 2;        // false
var q = 2 < 3;        // true
var result = p || q;  // true
The above example demonstrates an inclusive disjunction (meaning it includes cases where both operands are true). Disjunctions can also be exlusive. An exclusive disjunction is typically represented by "⊻" and is true if and only if both operands have opposite values.
p = 1 < 2 = true
q = 2 < 3 = true
therefore p ⊻ q is false
This can become confusing when dealing with more than 2 operands.
r = 3 < 4 = true
p ⊻ q ⊻ r = ???
We handle these situations by evaluating the expression from left to right.
p ⊻ q = false
(p ⊻ q) ⊻ r = true
Directions:
For this kata, your task is to implement a function that performs a disjunction operation on 2 or more propositions.

Should take a boolean array as its first parameter and a single boolean as its second parameter, which, if true, should indicate that the disjunction should be exclusive as opposed to inclusive.
Should return true or false.

Source: codewars | Difficulty: EASY
Tags: Mathematics

Starter code: def disjunction(operands, is_exclusive):
	

Solutions:
from functools import reduce

def disjunction(operands, is_exclusive):
	return reduce(bool.__xor__ if is_exclusive else bool.__or__, operands)


from functools import reduce

def disjunction(operands, is_exclusive):
	op = int.__xor__ if is_exclusive else int.__or__
	return reduce(op, operands)


from functools import reduce
from operator import or_, xor

def disjunction(operands, is_exclusive):
	return reduce(xor if is_exclusive else or_, operands)


disjunction = lambda o, e: o.count(True) % 2 if e else True in o


from functools import reduce

def disjunction(operands, is_exclusive):
	return reduce(getattr(bool, f"__{('x' if is_exclusive else '')}or__"), operands)


def disjunction(operands, is_exclusive):
	return sum(operands) & 1 if is_exclusive else any(operands)


def disjunction(operands, is_exclusive):
	return sum(operands) % 2 if is_exclusive else any(operands)


from functools import reduce
from operator import xor, or_
disjunction = lambda a, b: reduce(xor if b else or_, a)