Code Deduction

Source

I got this problem from Oriel Maxime, who was inspired by the Turing Machine game. I slightly simplified the wording.

I solved it and wrote up my solution.

Problem    

Alice and Bob are considering codes consisting of three digits, each 1–5.

Alice has selected a code.

Alice emails Bob the following four pieces of data:

  • A: whether the middle digit is less than, equal to, or greater than 4;
  • B: whether the code consists of three identical digits, two identical digits with another different, or three different digits;
  • C: whether the sum of the digits is even or odd; and
  • D: how many 3s are in the code.

Bob replies: "Now I know the code. Good thing you sent me all four of those; I couldn't have been certain of the code if you hadn't sent them all."

What is the code?

Solution     Reveal