<claudexml/>
Reasoning · intermediate

Constraint-satisfaction logic puzzle

Solve a puzzle by enumerating constraints inside <thinking> and concluding in <answer>.

Zebra-style puzzles, scheduling problems, or any task that needs explicit constraint tracking.

The prompt

Copy this verbatim. Replace the {{ … }} placeholders with your values.

<instructions>
Solve the puzzle. Inside <thinking>:
1. List the entities and possible values.
2. List each constraint explicitly.
3. Deduce, eliminating possibilities; note any branches you tried.

Inside <answer>, give the final assignment as a JSON object.
</instructions>

<puzzle>{{ puzzle_text }}</puzzle>

Sample input

Three friends — Alex, Blair, Casey — each ordered a different drink (coffee, tea, juice). Alex didn't order coffee. Blair didn't order tea. Casey ordered tea. What did each person order?

Expected output

<thinking>
Entities: {Alex, Blair, Casey} → drinks {coffee, tea, juice}.
Constraints: Alex ≠ coffee; Blair ≠ tea; Casey = tea.
With Casey = tea, remaining {coffee, juice} for {Alex, Blair}.
Alex ≠ coffee → Alex = juice → Blair = coffee.
</thinking>
<answer>
{ "Alex": "juice", "Blair": "coffee", "Casey": "tea" }
</answer>

Notes & tuning tips

  • Numbered procedure beats free-form reasoning — Claude follows the structure.
  • JSON-in-answer makes downstream verification trivial.
  • For larger constraint problems (10+ entities), prefer a real solver (Z3, MiniZinc) called via tool use.

What this example uses

Tags: <instructions> <thinking> <answer>

Patterns: chain of thought structured output

Cite this page
Constraint-satisfaction logic puzzle. claudexml.com. https://claudexml.com/examples/logic-puzzle/