Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Boolean Algebra by capback250
OPERATION_NAMES = ("conjunction", "disjunction", "implication", "exclusive", "equivalence")
#now i can do it with dict, but i want save this for memories
def boolean(x, y, operation):
if operation == "conjunction":
if x == y == 1:
return 1
else:
return 0
if operation == "disjunction":
return x | y
if operation == "implication":
if x == 1 and y == 0:
return 0
else:
return 1
if operation == "exclusive":
if x == y:
return 0
else:
return 1
if operation == "equivalence":
if x == y:
return 1
else:
return 0
Feb. 9, 2016