Skip to content

Instantly share code, notes, and snippets.

@podhmo
Created August 18, 2010 11:49
Show Gist options
  • Save podhmo/534434 to your computer and use it in GitHub Desktop.
Save podhmo/534434 to your computer and use it in GitHub Desktop.
(use '[clojure.contrib.combinatorics :only (cartesian-product )])
;;●◆■▲★×4=★▲■◆●
(let [coll-to-num
(fn [coll]
(reduce #(+ (* %1 10) %2) 0 coll))]
(for [nums (apply cartesian-product (repeat 5 (range 0 10)))
:when (= (* 4 (coll-to-num nums))
(coll-to-num (reverse nums)))]
nums))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment