Forked from josepablocam/gist:78282c068f774961f1f4ab1330174c90
Last active
February 27, 2026 21:59
-
-
Save ferhaterata/2ae637f8341eeb792092765850814642 to your computer and use it in GitHub Desktop.
pizza puzzles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Rachel's Pizza Ordering Puzzle | |
| ; | |
| ; Rachel is ordering pizza for seven people. She spilled coffee on her | |
| ; list but can reconstruct it from what she remembers about preferences. | |
| ; The coffee-stained list shows the 7 pizzas ordered and a visible "N" | |
| ; (end of a name) next to Sausage. | |
| (set-logic QF_DT) | |
| ; --- Pizza types (from the coffee-stained list) --- | |
| (declare-datatypes ((Pizza 0)) (( | |
| (Cheese) (Pepperoni) (Margherita) (Hawaiian) (BBQChicken) (PeppersOnions) (Sausage) | |
| ))) | |
| ; --- Each person's order --- | |
| (declare-const rachel Pizza) | |
| (declare-const emily Pizza) | |
| (declare-const owen Pizza) | |
| (declare-const yasmine Pizza) | |
| (declare-const nathan Pizza) | |
| (declare-const wendy Pizza) | |
| (declare-const kevin Pizza) | |
| ; --- Pizza properties --- | |
| (define-fun is-vegetarian ((p Pizza)) Bool | |
| (or (= p Cheese) (= p Margherita) (= p PeppersOnions))) | |
| (define-fun has-meat ((p Pizza)) Bool | |
| (or (= p Pepperoni) (= p Hawaiian) (= p BBQChicken) (= p Sausage))) | |
| (define-fun has-onions ((p Pizza)) Bool | |
| (= p PeppersOnions)) | |
| (define-fun has-pineapple ((p Pizza)) Bool | |
| (= p Hawaiian)) | |
| (define-fun is-classic ((p Pizza)) Bool | |
| (or (= p Cheese) (= p Pepperoni) (= p Margherita))) | |
| ; --- Constraints --- | |
| ; Everyone orders something different (7 people, 7 pizzas) | |
| (assert (distinct rachel emily owen yasmine nathan wendy kevin)) | |
| ; Emily and Owen are vegetarians | |
| (assert (is-vegetarian emily)) | |
| (assert (is-vegetarian owen)) | |
| ; Yasmine thinks plain Cheese is boring | |
| (assert (not (= yasmine Cheese))) | |
| ; Nathan likes the classics: Cheese, Pepperoni, or Margherita | |
| (assert (is-classic nathan)) | |
| ; Emily hates onions | |
| (assert (not (has-onions emily))) | |
| ; Wendy doesn't believe pineapple belongs on a pizza | |
| (assert (not (has-pineapple wendy))) | |
| ; Rachel ordered Cheese | |
| (assert (= rachel Cheese)) | |
| ; Kevin always wants a pizza with meat on it | |
| (assert (has-meat kevin)) | |
| ; Visible "N" next to Sausage: the orderer's name ends in N | |
| ; (Nathan, Owen, or Kevin) | |
| (assert (or (= nathan Sausage) (= owen Sausage) (= kevin Sausage))) | |
| (check-sat) | |
| (get-model) |
Author
ferhaterata
commented
Feb 27, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment