Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (with-test
- (defn maximal-path [tree-file]
- (with-open [rdr (BufferedReader. (FileReader. tree-file))]
- (let [lines (reverse
- (map
- (fn [x]
- (map #(Integer. %) (re-seq #"\d+" x)))
- (line-seq rdr)))]
- (first
- (reduce
- (fn [a b]
- (map max (map + b a) (map + b (rest a))))
- lines)))))
- (is (= (maximal-path "prob_18.txt") 1074))
- (is (= (maximal-path "prob_67.txt") 7273)))
Add Comment
Please, Sign In to add comment