Skip to content

Instantly share code, notes, and snippets.

@katsuyan
Created October 26, 2017 11:31
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/019ffb62fca19b2cefa003d33b08cadf to your computer and use it in GitHub Desktop.
Save katsuyan/019ffb62fca19b2cefa003d33b08cadf to your computer and use it in GitHub Desktop.
数学パズルonClojure-Q15
(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