-
-
Save coldnew/8cf373006d0caa1c3df9 to your computer and use it in GitHub Desktop.
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
(defn solve | |
[grid] | |
(remove nil? | |
(run* [q] | |
(macro/symbol-macrolet [_ (lvar)] | |
(== q grid) | |
(conde | |
((== grid [[q _ _] | |
[_ q _] | |
[_ _ q]])) | |
((== grid [[_ _ q] | |
[_ q _] | |
[q _ _]])) | |
((== grid [[q _ _] | |
[q _ _] | |
[q _ _]])) | |
((== grid [[_ q _] | |
[_ q _] | |
[_ q _]])) | |
((== grid [[_ _ q] | |
[_ _ q] | |
[_ _ q]])) | |
((== grid [[q q q] | |
[_ _ _] | |
[_ _ _]])) | |
((== grid [[_ _ _] | |
[q q q] | |
[_ _ _]])) | |
((== grid [[_ _ _] | |
[_ _ _] | |
[q q q]]))))))) | |
(solve [[:y :x :y] | |
[nil :x nil] | |
[nil :x nil]]) | |
; => (:x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment