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
maxPath (x:y:xs) = maxPath (z:xs) | |
where z = zipWith (+) (zipWith max x (tail x)) y | |
maxPath [[x]] = x | |
convert = map (map read . words) | |
prob67 = show . maxPath . reverse . convert . lines | |
main = readFile "triangle.txt" >>= putStrLn . prob67 |
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
(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 |
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
fibs = Fiber.new do | |
x1, x2 = 1, 2 | |
loop do | |
Fiber.yield x1 | |
x1, x2 = x2, x2+x1 | |
end | |
end | |
sum = 0 | |
begin |
NewerOlder