Created
October 26, 2017 11:31
-
-
Save katsuyan/019ffb62fca19b2cefa003d33b08cadf to your computer and use it in GitHub Desktop.
数学パズルonClojure-Q15
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.q15) | |
(def n 10) | |
(def steps 4) | |
(defn move-pares [max-num] | |
(for [i (range 1 (inc max-num)) | |
j (range 1 (inc max-num))] [i j])) | |
(defn move [steps a b cnt] | |
(cond | |
(> a b) 0 | |
(= a b) 1 | |
:else (+ cnt | |
(reduce + (map (fn [move-pare] (apply #(move steps (+ a %1) (- b %2) cnt) move-pare)) | |
(move-pares steps)))))) | |
(def answer (move steps 0 n 0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment