Hi all, Does anyone wanna have a look at my solution for Project Euler Problem 28?
(defn diagonal-sum [n-max] (+ 1 (reduce + (map (fn[n] (reduce + (map #(- (* n n) (* % (- n 1))) (range 4)))) (take-nth 2 (range 3 (+ 2 n-max))))))) The function does the job. The solution takes about 1.5msec on my machine to compute. I'd like to discuss more performant and/or more idiomatic solutions to that problem :) The parts I'm not quite happy with are the take-nth and range constructs with all the magic numbers in there... Cheers Andreas -- "Programs must be written for people to read, and only incidentally for machines to execute." - Abelson & Sussman, SICP -- ********************************************************** Andreas Koestler, Software Engineer Leica Geosystems Pty Ltd 270 Gladstone Road, Dutton Park QLD 4102 Main: +61 7 3891 9772 Direct: +61 7 3117 8808 Fax: +61 7 3891 9336 Email: andreas.koest...@leica-geosystems.com ************www.leica-geosystems.com************* when it has to be right, Leica Geosystems Please consider the environment before printing this email. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en