Created
June 25, 2017 02:16
-
-
Save katsuyan/db303eaa57b5bd9a580e8a757a156f3c to your computer and use it in GitHub Desktop.
数学パズルonClojure-Q8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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