Created
May 29, 2015 05:53
-
-
Save hikoz/a1331464559b744b4668 to your computer and use it in GitHub Desktop.
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
(->> | |
(let [[h & t] (range 1 10)] | |
(reduce | |
(fn [l h] | |
(mapcat (fn [[a b s]] | |
[[(conj a b) h (str s " + " h)] | |
[(conj a b) (- h) (str s " - " h)] | |
[a (bigint (str b h)) (str s h)]]) | |
l)) | |
[[[] h h]] | |
t)) | |
(filter #(= (apply + (second %) (first %)) 100)) | |
(map #(nth % 2))) |
for
(let [[h & l] (range 1 10)
r (loop [r [[[] h h]]
[h & t] l]
(if h
(recur
(mapcat (fn [[a b s]]
[[(conj a b) h (str s " + " h)]
[(conj a b) (- h) (str s " - " h)]
[a (bigint (str b h)) (str s h)]])
r)
t)
r))]
(for [[a b c] r :when (= (apply + b a) 100)] c))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
loop