Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created July 3, 2012 21:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save swannodette/3043632 to your computer and use it in GitHub Desktop.
Save swannodette/3043632 to your computer and use it in GitHub Desktop.
dinesman.clj
(ns dinesman
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defne aboveo [x y l]
([_ _ [y . r]]
(membero x l))
([_ _ [z . r]]
(!= z y)
(aboveo x y r)))
(defne not-above1o [x y l]
([_ _ ()])
([_ _ [a . ()]])
([_ _ [a x . r]] (!= a y))
([_ _ [_ a . r]]
(!= a x)
(fresh [nl]
(conso a r nl)
(not-above1o x y nl))))
(defn not-adjacento [x y l]
(all
(not-above1o x y l)
(not-above1o y x l)))
(run* [q]
(fresh [a b c d e]
(== q [a b c d e])
(permuteo [:Baker :Cooper :Fletcher :Miller :Smith] q)
(!= e :Baker) (!= a :Cooper)
(!= e :Fletcher) (!= a :Fletcher)
(aboveo :Miller :Cooper q)
(not-adjacento :Smith :Fletcher q)
(not-adjacento :Fletcher :Cooper q)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment