Last active
September 28, 2015 06:38
-
-
Save ypsilon-takai/1400109 to your computer and use it in GitHub Desktop.
project euler 67
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; reviced for clojure 1.4 | |
| ;; Problem 67 : 2011/11/28 | |
| ;; "Elapsed time: 52.128413 msecs" | |
| (defn pe-67 [input-list] | |
| (apply max | |
| (reduce (fn [root new] | |
| (let [rt-r (cons 0 root) | |
| rt-l (conj root 0)] | |
| (mapv #(+ %1 (max %2 %3)) | |
| new rt-l rt-r))) | |
| input-list))) | |
| ;; Support func to read data from the file. | |
| (require '[clojure.java.io :as io]) | |
| (defn pe-67-with-file [input-file] | |
| (with-open [in-file (io/reader input-file)] | |
| (pe-67 | |
| (mapv (fn [line-dat] | |
| (mapv (fn [s] (Integer. s)) | |
| (.split line-dat " "))) | |
| (line-seq in-file))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment