Skip to content

Instantly share code, notes, and snippets.

@ypsilon-takai
Created December 1, 2011 06:33
Show Gist options
  • Select an option

  • Save ypsilon-takai/1414335 to your computer and use it in GitHub Desktop.

Select an option

Save ypsilon-takai/1414335 to your computer and use it in GitHub Desktop.
project euler 68
;; Problem 68 : 2011/12/1
;;"Elapsed time: 89.450754 msecs"
(defn check-pe68 [tgt]
(let [[[a2 a3 a4 a5] [b1 b2 b3 b4 b5]] tgt]
(if (= 14
(+ 6 b1 b2) (+ a2 b2 b3) (+ a3 b3 b4)
(+ a4 b4 b5) (+ a5 b5 b1))
[6 b1 b2 a2 b2 b3 a3 b3 b4 a4 b4 b5 a5 b5 b1]
false)))
(defn pe68 []
(filter check-pe68
(for [out (comb/permutations (range 7 11))
in (comb/permutations (range 1 6))]
[out in])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment