# A Robot's Last Words

There, spread out all over the floor, were the mechanical pieces of a robot. Something had torn it apart, and the debris spanned a radius of a few meters. There was no sign of what might have caused this tragedy. What monster, what disaster, could cause this much damage to a mechanical creature?

However, a few steps away, there was a hastily constructed circuit:

And one question nags at you:

What was the robot trying to tell us with his last words?

• Wow! Nice intuitive riddle... just one question - how the hell did you come up with the boolean formulas from the results/truth-table ? Dec 18 '14 at 13:43
• @Falco: a naive approach would be to take all rows where a certain bit evaluates to 1 and 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.
– Groo
Sep 26 '15 at 8:19

KEEPAWAY

Explanation:

Here are the functions for the output (in Java).

Output 1 = !((!C)|C)
Output 2 = (!C)|C
Output 3 = !((!C)|C)
Output 4 = (A|B)&C
Output 5 = (!(A^B))&(!(B^C))
Output 6 = ((!A)&(B^C))|((A&C)&(!B))
Output 7 = ((A&C)&(!B))|(!((B|C)|A))
Output 8 = (!(B&C))|A


Using these functions

you can create a Truth table:  |A|B|C|1|2|3|4|5|6|7|8|Hex|Char| -------------------------------- |0|0|0|0|1|0|0|1|0|1|1|4b |K | |0|0|1|0|1|0|0|0|1|0|1|45 |E | |0|1|0|0|1|0|0|0|1|0|1|45 |E | |0|1|1|0|1|0|1|0|0|0|0|50 |P | |1|0|0|0|1|0|0|0|0|0|1|41 |A | |1|0|1|0|1|0|1|0|1|1|1|57 |W | |1|1|0|0|1|0|0|0|0|0|1|41 |A | |1|1|1|0|1|0|1|1|0|0|1|59 |Y |  From this truth table it is obvious what the message is.

• Completely correct! Dec 18 '14 at 0:46
• This is clever, @Tryth, and I enjoyed solving it. I'm curious how the message ties in with the story, however.
– jscs
Dec 18 '14 at 1:17
• @JoshCaswell My idea was that whatever destroyed the robot was so dangerous that with his last seconds he created a warning for others. Not sure how well it was conveyed though. Dec 18 '14 at 1:37
• Sounds like you set yourself up for a sequel, @Tryth!
– jscs
Dec 18 '14 at 1:42
• @Tryth I don't think the answer is completely correct. I think there is a mistake in upper cases vs. lower case. Dec 18 '14 at 9:04

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