Revisions
-
swannodette revised this gist
Aug 1, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ y (range 0 9 3)] (get-square rows x y))] (run 1 [q] (== q vars) (everyo #(infd % (domain 1 2 3 4 5 6 7 8 9)) vars) (init vars hints) (everyo distinctfd rows) -
swannodette revised this gist
Aug 1, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ sqs (for [x (range 0 9 3) y (range 0 9 3)] (get-square rows x y))] (run 1 [q] (== q rows) (everyo #(infd % (domain 1 2 3 4 5 6 7 8 9)) vars) (init vars hints) -
swannodette revised this gist
Aug 1, 2012 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,10 +11,10 @@ (if (seq vars) (let [hint (first hints)] (all (if-not (zero? hint) (== (first vars) hint) succeed) (init (next vars) (next hints)))) succeed)) (defn sudokufd [hints] -
swannodette revised this gist
Aug 1, 2012 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,8 +17,6 @@ (init (next vars) (next hints)))) succeed)) (defn sudokufd [hints] (let [vars (repeatedly 81 lvar) rows (->> vars (partition 9) (map vec) (into [])) -
swannodette revised this gist
Aug 1, 2012 . 1 changed file with 18 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -32,4 +32,21 @@ (init vars hints) (everyo distinctfd rows) (everyo distinctfd cols) (everyo distinctfd sqs)))) ;; ==== (comment (sudokufd [0 0 3 0 2 0 6 0 0 9 0 0 3 0 5 0 0 1 0 0 1 8 0 6 4 0 0 0 0 8 1 0 2 9 0 0 7 0 0 0 0 0 0 0 8 0 0 6 7 0 8 2 0 0 0 0 2 6 0 9 5 0 0 8 0 0 2 0 3 0 0 9 0 0 5 0 1 0 3 0 0]) ) -
swannodette revised this gist
Aug 1, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ (init (next vars) (next hints)))) succeed)) ;; hints is a vector of integers, only values ;; that are not zero will be used (defn sudokufd [hints] (let [vars (repeatedly 81 lvar) -
swannodette revised this gist
Aug 1, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,8 @@ (init (next vars) (next hints)))) succeed)) ;; hints is a vector of integer, only values ;; that are not zero will be used (defn sudokufd [hints] (let [vars (repeatedly 81 lvar) rows (->> vars (partition 9) (map vec) (into [])) -
swannodette revised this gist
Aug 1, 2012 . 1 changed file with 19 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,26 +2,33 @@ (:refer-clojure :exclude [==]) (:use clojure.core.logic)) (defn get-square [rows x y] (for [x (range x (+ x 3)) y (range y (+ y 3))] (get-in rows [x y]))) (defn init [vars hints] (if (seq vars) (let [hint (first hints)] (all (if-not (zero? hint) (== (first vars) hint) succeed) (init (next vars) (next hints)))) succeed)) ;; hints is vectors of ints, only values that are not zero will be used (defn sudokufd [hints] (let [vars (repeatedly 81 lvar) rows (->> vars (partition 9) (map vec) (into [])) cols (apply map vector rows) sqs (for [x (range 0 9 3) y (range 0 9 3)] (get-square rows x y))] (run-nc 1 [q] (== q rows) (everyo #(infd % (domain 1 2 3 4 5 6 7 8 9)) vars) (init vars hints) (everyo distinctfd rows) (everyo distinctfd cols) (everyo distinctfd sqs)))) -
swannodette revised this gist
Jul 31, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ (defn init [grid [pos value]] (== (get-in grid pos) value)) (defn sudokufd [hints] (let [vs (repeatedly 81 lvar) grid (->> vs (partition 9) (map vec) (into [])) rows grid @@ -21,7 +21,7 @@ (run-nc 1 [q] (== q grid) (everyo #(infd % (domain 1 2 3 4 5 6 7 8 9)) vs) (everyo (partial init grid) hints) (everyo distinctfd rows) (everyo distinctfd cols) (everyo distinctfd sqs)))) -
swannodette revised this gist
Jul 31, 2012 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ (ns sudoku (:refer-clojure :exclude [==]) (:use clojure.core.logic)) (defn get-square [grid x y] (for [x (range x (+ x 3)) y (range y (+ y 3))] @@ -20,4 +24,4 @@ (everyo (partial init grid) initial) (everyo distinctfd rows) (everyo distinctfd cols) (everyo distinctfd sqs)))) -
swannodette revised this gist
Jul 31, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ (defn init [grid [pos value]] (== (get-in grid pos) value)) (defn sudokufd [initial] (let [vs (repeatedly 81 lvar) grid (->> vs (partition 9) (map vec) (into [])) rows grid -
swannodette created this gist
Jul 31, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ (defn get-square [grid x y] (for [x (range x (+ x 3)) y (range y (+ y 3))] (get-in grid [x y]))) (defn init [grid [pos value]] (== (get-in grid pos) value)) (defn big-sudokufd [initial] (let [vs (repeatedly 81 lvar) grid (->> vs (partition 9) (map vec) (into [])) rows grid cols (apply map vector grid) sqs (for [x (range 0 9 3) y (range 0 9 3)] (get-square grid x y))] (run-nc 1 [q] (== q grid) (everyo #(infd % (domain 1 2 3 4 5 6 7 8 9)) vs) (everyo (partial init grid) initial) (everyo distinctfd rows) (everyo distinctfd cols) (everyo distinctfd sqs))))