   (= (count board) (count (solved-tiles board))))
 
 (defn goal-coord [board tile]
-  (index->coords board (- (if (= tile 0)
-                            (count board)
-                            tile) 1)))
+  (index->coords board (dec (if (= tile 0)
+                              (count board)
+                              tile))))
 
 (defn last-on-row? [board [x y]]
-  (= x (- (dimension board) 1)))
+  (= x (dec (dimension board))))
 
 (defn move-sequence [board [tile goal solved] & more]
   (let [path (move-to board tile goal solved)]

      (if (last-on-row? board goal)
        (let [row-min (coords->tile board [0 y])]
          (move-sequence board
                         [tile [x (+ y 1)] solved]
                         [0 [0 y] (conj (disj solved row-min) tile)]
                         [0 [x y] #{}]
                         [tile [x y] solved]
                         [0 [(- x 1) y] #{tile}]
                         [row-min [0 y] #{tile}]
                         ))
        (move-to board tile goal solved)))))

(defn solve-next [board]
  (if (solved? board)
    []
    (let [next (inc (count (solved-tiles board)))]
      (solve-tile board next))))
