Guest User

Untitled

a guest
May 27th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. (with-test
  2. (defn maximal-path [tree-file]
  3. (with-open [rdr (BufferedReader. (FileReader. tree-file))]
  4. (let [lines (reverse
  5. (map
  6. (fn [x]
  7. (map #(Integer. %) (re-seq #"\d+" x)))
  8. (line-seq rdr)))]
  9. (first
  10. (reduce
  11. (fn [a b]
  12. (map max (map + b a) (map + b (rest a))))
  13. lines)))))
  14.  
  15. (is (= (maximal-path "prob_18.txt") 1074))
  16. (is (= (maximal-path "prob_67.txt") 7273)))
Add Comment
Please, Sign In to add comment