Search code examples
logiccomputer-scienceboolean-logictruthtablezebra-puzzle

Truth table for the zebra puzzle


I'm reading "Computer Science distilled" book and I've faced a trouble. Author suggests to solve Einstein's "Zebra puzzle" through truth table, but I can't figure out how. I can't find starting conditions and variables. Do you have any ideas of the smallest table possible? I suppose I can create only a 6^6 version


Solution

  • I'm the author of the book the OP mentioned. I didn't mean for the reader to use only a big truth table to solve the Zebra Puzzle, but rather, so use it as a tool to detect situations that can never happen, and to better direct the exploration process.

    Using a big truth table with variables representing a house/attribute state, you can spot a variable that, if true, would imply a lot of relevant states. It's best to test these variables for finding logical contradictions than simply bruteforcing all the variables.

    I wrote a detailed blog post explaining how to solve the Zebra puzzle using only simple inferences and boolean algebra, here: https://code.energy/solving-zebra-puzzle/