-
-
Save ahoy-jon/5189e9384e1a8197f6a2 to your computer and use it in GitHub Desktop.
Solution for https://github.com/jeanlaurent/secretSanta in core.logic
This file contains 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
(ns cdl.santa | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic])) | |
;; https://github.com/jeanlaurent/secretSanta | |
(def data | |
(partition 2 '[Walter White | |
Skyler White | |
Gustavo Fring | |
Saul Goodman | |
Jesse Pinkman | |
Henry Schrader | |
Marie Schrader])) | |
(defne oreo | |
"MMmmm COOOKIES" ;; I don't know how to name that one | |
[x y z] | |
([a a a]) | |
([a b a] (!= a b)) | |
([b a a] (!= a b))) | |
(defne zipo | |
"zipped = (map (partial vector) xl yl)" | |
[xl yl zipped] | |
([xs ys ()] (oreo xs ys ())) | |
([[x . xs] [y . ys] [z . zs]] | |
(== z [x y]) | |
(zipo xs ys zs))) | |
(defne ruleo [z] | |
([()]) | |
([[[[_ x] [_ y]] . as]] ; extract names of the first pair | |
(!= x y) | |
(ruleo as))) | |
(run 10 [couple] | |
(fresh [result] | |
(zipo data result couple) | |
(permuteo data result) | |
(ruleo couple))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In fact, oreo is a materialized version of membero, so it's not really useful :