     (if (seq diagonals)
       (let [k (first diagonals)
             [x y] (next-point d k v)
-            x (longest-snake a b x y n m)
+            x (snake a b x y n m)
             y (- x k)
             v (assoc v k x)]
         (if (and (>= x n) (>= y m))

            (recur (rest d-range) endpoints)))
        [(+ n m) (- n m) endpoints]))))

(defn- optimal-path
  "Reconstruct the optimal path from source to sink using the information
  produced by the ses function."
  [a b d k endpoints]

            prev-v (get endpoints (dec d))
            [prev-k b] (if (< (x-down prev-v k) (x-up prev-v k))
                         [(inc k) (x-up prev-v k)]
                         [(dec k) (inc (x-down prev-v k))])
            result (reduce conj
                           (conj result [x y])
                           (reverse
