(def all-path-count
  (memoize 
   (fn [m n x y x1 y1 k]
    (if (== k 0)
      (if (and (== x x1) (== y y1)) 1 0)
      (+'
        (if (< (inc y) n) (all-path-count m n x (inc y) x1 y1  (dec k)) 0 )
        (if (>= (dec y) 0) (all-path-count m n x (dec y) x1 y1 (dec k)) 0 )
        (if (< (inc x) m) (all-path-count m n (inc x) y x1 y1 (dec k)) 0 )
        (if (>= (dec x) 0) (all-path-count m n (dec x) y x1 y1 (dec k)) 0))))))

;;(all-path-count 3 3 0 0 2 2 4)

;;(def all-path-count (memoize step))

;;(print (all-path-count 3 3 0 0 2 2 14))
;;(print (all-path-count 3 3 0 0 2 2 20))
(print (all-path-count 100 100 50 50 60 60 150))