fork download
  1. (def all-path-count
  2. (memoize
  3. (fn [m n x y x1 y1 k]
  4. (if (== k 0)
  5. (if (and (== x x1) (== y y1)) 1 0)
  6. (+'
  7. (if (< (inc y) n) (all-path-count m n x (inc y) x1 y1 (dec k)) 0 )
  8. (if (>= (dec y) 0) (all-path-count m n x (dec y) x1 y1 (dec k)) 0 )
  9. (if (< (inc x) m) (all-path-count m n (inc x) y x1 y1 (dec k)) 0 )
  10. (if (>= (dec x) 0) (all-path-count m n (dec x) y x1 y1 (dec k)) 0))))))
  11.  
  12. ;;(all-path-count 3 3 0 0 2 2 4)
  13.  
  14. ;;(def all-path-count (memoize step))
  15.  
  16. ;;(print (all-path-count 3 3 0 0 2 2 14))
  17. ;;(print (all-path-count 3 3 0 0 2 2 20))
  18. (print (all-path-count 100 100 50 50 60 60 150))
Time limit exceeded #stdin #stdout 5s 335488KB
stdin
Standard input is empty
stdout
Standard output is empty