Advertisement
Guest User

Untitled

a guest
Dec 25th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; surely there's a cleaner way?
  2. ;; all-conts gives a list of lists of pairs: (([1 0] [2 0] ...) ... )
  3. ;; the point is to lookup the 2d coordinate given by a pair and multiply all
  4. ;; such values in one list together, then choose the largest one
  5. ;; (see http://projecteuler.net/problem=11)
  6. (defn find-largest-product [size]
  7.   (->> (all-conts size)
  8.        (map #(->> %
  9.                   (map lookup)
  10.                   (reduce *)))
  11.        (reduce max)))
  12.  
  13. (reduce max (map #(reduce * (map lookup %))
  14.             (all-conts size))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement