Skip to content

Instantly share code, notes, and snippets.

@thickey
Forked from swannodette/gist:3043632
Created January 14, 2013 19:02
Show Gist options
  • Save thickey/4532399 to your computer and use it in GitHub Desktop.
Save thickey/4532399 to your computer and use it in GitHub Desktop.
(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