fork download
  1. (defn n-digits [digits]
  2. (let
  3. [low (nth (iterate (partial * 10) 1) (dec digits))
  4. high (dec (nth (iterate (partial * 10) 1) digits))]
  5. (vector low high)))
  6.  
  7. (defn n-digit-products [digits]
  8. (let [[low high] (n-digits digits)]
  9. (distinct
  10. (for [x (range low (inc high)) y (range low (inc high)) :while (<= y x)]
  11. (* x y)))))
  12.  
  13. (defn palindromic-products [digits]
  14. (reverse (sort (filter #(= (seq (str %)) (reverse (str %))) (n-digit-products digits)))))
  15.  
  16. (println palindromic-products 2)
Success #stdin #stdout 0.93s 214656KB
stdin
Standard input is empty
stdout
#<user$palindromic_products__34 user$palindromic_products__34@15bdc50> 2