Skip to content

Instantly share code, notes, and snippets.

@katsuyan
Created June 25, 2017 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katsuyan/db303eaa57b5bd9a580e8a757a156f3c to your computer and use it in GitHub Desktop.
Save katsuyan/db303eaa57b5bd9a580e8a757a156f3c to your computer and use it in GitHub Desktop.
数学パズルonClojure-Q8
(ns puzzule.q8)
(defn walk [move-num current route]
(if (some #(= % current) route)
0
(if (= move-num 0)
1
(+ (walk (dec move-num) [(inc (first current)) (second current)] (conj route current))
(walk (dec move-num) [(dec (first current)) (second current)] (conj route current))
(walk (dec move-num) [(first current) (inc (second current))] (conj route current))
(walk (dec move-num) [(first current) (dec (second current))] (conj route current))))))
(walk 12 [0 0] [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment