Commits

John Chandler  committed 3a8cc6c

replaced refine-row and refine-column with refine-line

  • Participants
  • Parent commits 5da0e21

Comments (0)

Files changed (2)

File src/pseudohkoo/core.clj

        line))
 
 ;; row functions
-(defn refine-row [row]
-  ; return a row with non-definite values refined, where possible
-  (refine-line row))
-
 (defn row-complete? [row]
   ; returns true if row has been completed or false if not
   (= (required-values row) (set row)))
   ; retrieve all columns from the grid (this is like flipping the grid along a diagonal)
   (map (fn [index] (get-column grid index)) (range (count (first grid)))))
 
-(defn refine-column [column]
-  ; return a column with non-definite values refined, where possible
-  (refine-line column))
-
 ;; grid functions
 (defn refine [grid]
   ; returns vector of refined columns
   (map
    (fn [column]
-     (refine-column column))
-   (get-columns (map refine-row grid))))
+     (refine-line column))    ; refine columns
+   (get-columns
+    (map refine-line grid)))) ; refine rows
 
 (defn remap-columns-to-grid [columns grid]
   ; remaps refined columns back to the grid

File test/pseudohkoo/test/core.clj

     (is (true? (grid-complete? grid)))))
 
 
-;; refine-row
-(deftest test-refine-row-nearly-done
-  ; test refining of a "nearly done" row i.e. we're missing a value or two
-  (is (= [1 2 3, 4 5 6, 7 8 9]         (refine-row [1 2 3, 4 5 6, 7 8 nil])))
-  (is (= [1 2 [3 9], 4 5 6, 7 8 [3 9]] (refine-row [1 2 nil, 4 5 6, 7 8 nil])))
-  (is (= [1 2 3, 4 5 6, 7 8 9]         (refine-row [1 2 3, 4 5 6, 7 8 [3 9]]))))
-
-
-;; refine-column
-(deftest test-refine-column-nearly-done
-  ; test refining of a "nearly done" column i.e. we're missing a value or two
-  (is (= [1 2 3, 4 5 6, 7 8 9]         (refine-column [1 2 3, 4 5 6, 7 8 nil])))
-  (is (= [1 2 [3 9], 4 5 6, 7 8 [3 9]] (refine-column [1 2 nil, 4 5 6, 7 8 nil])))
-  (is (= [1 2 3, 4 5 6, 7 8 9]         (refine-column [1 2 3, 4 5 6, 7 8 [3 9]]))))
+;; refine-line
+(deftest test-refine-line-nearly-done
+  ; test refining of a "nearly done" line i.e. we're missing a value or two
+  (is (= [1 2 3, 4 5 6, 7 8 9]         (refine-line [1 2 3, 4 5 6, 7 8 nil])))
+  (is (= [1 2 [3 9], 4 5 6, 7 8 [3 9]] (refine-line [1 2 nil, 4 5 6, 7 8 nil])))
+  (is (= [1 2 3, 4 5 6, 7 8 9]         (refine-line [1 2 3, 4 5 6, 7 8 [3 9]]))))
 
 
 ;; remap-columns-to-grid