a b c =00 0 0 0 10 0 1 1 20 1 0 0 30 1 1 1 41 0 0 1 51 0 1 1 61 1 0 1 71 1 1 1 def bin_values(in_int): ret = [] b = bin(in_int)[2:] while len(b) != 3: b = '0' + b for i in b: ret.append(bool(int(i))) return retfor xs in range(2**3): a, b, c = bin_values(xs) print(xs) res = a and not c or c and (b or not c) or (a or not b) and c print(int(a), int(b), int(c), int(res), "")