Taking the bottom output as bit 0 up to the top output as bit 7. You can easily see that bits 5, 6, and 7 are always 010. Given that I wrote the following Python code (without looking at any answers to make it more fun!):
def bit0(a, b, c):
return a or not (b and c)
def bit1(a, b, c):
return bit1_5(a, b, c) or not (a or b or c)
def bit1_5(a, b, c):
return (a and c) and not b
def bit2(a, b, c):
return (not a and (b != c)) or bit1_5(a, b, c)
def bit3(a, b, c):
return a == b == c
def bit4(a, b, c):
return (a or b) and c
def compose(i):
a = bool(i & 0x04)
b = bool(i & 0x02)
c = bool(i & 0x01)
bits = 0b01000000
if bit0(a, b, c):
bits |= 0b00000001
if bit1(a, b, c):
bits |= 0b00000010
if bit2(a, b, c):
bits |= 0b00000100
if bit3(a, b, c):
bits |= 0b00001000
if bit4(a, b, c):
bits |= 0b00010000
return bits
if __name__ == '__main__':
message = ''
for i in range(8):
message += chr(compose(i))
print (message)
Which outputs:
KEEPAWAY
OR
them. But a better way is to build a Karnaugh map for each bit, which gives you the simplest boolean expression equivalent to the naive one. $\endgroup$