Project Euler #81 in Haskell: minimal path sum through a matrix











up vote
1
down vote

favorite












I just completed Project Euler Problem 81 in Haskell:




In the 5 by 5 matrix below,



131   673 234 103 18
201 96 342 965 150
630 803 746 422 111
537 699 497 121 956
805 732 524 37 331


the minimal path sum from the top left to
the bottom right, by only moving to the right and down, is



131 → 201 → 96 → 342 → 746 → 422 → 121 → 37 → 331


and is equal to 2427.



Find the minimal path sum, in matrix.txt, a 31K text file containing a 80 by 80 matrix,
from the top left to the bottom right by only moving right and down.




I'm looking for feedback on a few specific aspects, but I appreciate general feedback and style suggestions as well. The raw code is available here. The program input is available here; the program needs to be run in the same folder as the input file.



The solution has two main parts:




  1. Reading a CSV file containing an 80x80 grid of integers into an array

  2. Traversing the array to accumulate the minimal path sum




{-|
file: p081.hs
title: Path sum: two ways
date: December 9, 2018

link: <https://projecteuler.net/problem=81>
-}

{-# LANGUAGE OverloadedStrings #-}

import Control.Arrow (first, (&&&), (***))
import Control.Monad (join, liftM, mapM)
import Data.Array (Array, Ix, array, bounds, (!))
import Data.Function (on)
import Data.Ix (inRange)
import Data.List (groupBy)
import Data.Maybe (fromJust)
import Data.Text (Text)
import qualified Data.Text as Text (lines, null, splitOn)
import qualified Data.Text.IO as TextIO (readFile)
import Data.Text.Read (decimal)

type Matrix a = Array (Int, Int) a

-- the shape of a matrix stored in a space-separated text file
textMatrixShape :: Text -> (Int, Int)
textMatrixShape = (length &&& length . Text.splitOn "," . head) . Text.lines

-- map over a monomorphic 2-tuple
mapTuple :: (a -> b) -> (a, a) -> (b, b)
mapTuple = join (***)

textMatrixBounds :: Text -> ((Int, Int), (Int, Int))
textMatrixBounds = (,) (0,0) . mapTuple (subtract 1) . textMatrixShape

-- from <https://hackage.haskell.org/package/either-5.0.1>
rightToMaybe :: Either a b -> Maybe b
rightToMaybe = either (const Nothing) Just

textMatrixElements :: Text -> Maybe [Int]
textMatrixElements = rightToMaybe
. fmap (map fst)
. mapM decimal
. concatMap (Text.splitOn ",")
. Text.lines

grid :: (Int, Int) -> [(Int, Int)]
grid (m, n) = [(i, j) | i <- [0..m - 1], j <- [0..n - 1]]

-- textMatrixAssocs :: Text -> Maybe [((Int, Int), Int)]
-- textMatrixAssocs t = liftM (zip ((grid . textMatrixShape) t)) (textMatrixElements t)

textMatrixAssocs :: Text -> Maybe [((Int, Int), Int)]
textMatrixAssocs = uncurry fmap . first zip
. (grid . textMatrixShape &&& textMatrixElements)

-- textMatrix :: Text -> Maybe (Matrix Int)
-- textMatrix t = liftM (array (textMatrixBounds t)) (textMatrixAssocs t)

textMatrix :: Text -> Maybe (Matrix Int)
textMatrix = uncurry fmap . first array . (textMatrixBounds &&& textMatrixAssocs)

rightAndDown :: Num a => Matrix a -> ((Int, Int), a) -> [((Int, Int), a)]
rightAndDown m (i, s) = [(i', s + m ! i')
| i' <- [fmap (+ 1) i, first (+ 1) i]
, inRange (bounds m) i']

-- | Blackbird combinator
(...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(...) = (.) . (.)
infix 8 ...

updateFrontier :: (Num a, Ord a) => Matrix a -> [((Int, Int), a)] -> [((Int, Int), a)]
updateFrontier = map minimum . groupBy ((==) `on` fst) ... concatMap . rightAndDown

minimalPathSum :: (Num a, Ord a) => Matrix a -> a
minimalPathSum m = go [((0, 0), m ! (0, 0))]
where
go f = case f' of
-> (minimum . map snd) f
_ -> go f'
where
f' = updateFrontier m f

p081 :: IO Int
p081 = do
t <- TextIO.readFile "p081_matrix.txt"
return (minimalPathSum . fromJust . textMatrix $ t)

main :: IO ()
main = do
print =<< p081


Questions



I tried to use a point-free style wherever I could. Are there more elegant ways to do this? Is it too obscure?



I used Text and Array for performance reasons. Are there any ways that I could further improve performance without re-writing the program?



In the first part, the file is read using Data.Text.IO.readFile. The shape of the text matrix is estimated using TextMatrixShape, which is used to determine the bounds of the array in TextMatrixBounds. This is not safe, as the number of elements in each line of the text file is not guaranteed to be the same in every line in general. Is there a better way to get the shape of the array?



The elements are extracted from the text file using textMatrixElements and converted into an association list in textMatrixAssocs. I'm worried that this might be an inefficient way to build an array, as the array appears to me to be traversed multiple times. I would greatly appreciate it if someone could shed some light on this.



What of my use of Maybe in my text* functions? Is this appropriate?



In textMatrixElements, I use the decimal reader from Data.Text.Read to convert text values into integers. Is there a nice way to make this function more polymorphic?



In the second part, I accumulate the minimum path sum to each point in a frontier, which is an association list of array indices and path sums. In rightAndDown, I construct a list of next moves from a frontier element. For every next move, I'm checking whether the index is in the bounds of the matrix m. Is this wasterful?



Note that I try to solve Project Euler problems without external dependencies, and I'm interested in learning how to do things in the general case, not just to solve this particular problem. I want to hardcode as little as possible.










share|improve this question




















  • 2




    Point free is cute, but only when it adds clarity. updateFrontier pushes that boundary.
    – Alex Reinking
    yesterday















up vote
1
down vote

favorite












I just completed Project Euler Problem 81 in Haskell:




In the 5 by 5 matrix below,



131   673 234 103 18
201 96 342 965 150
630 803 746 422 111
537 699 497 121 956
805 732 524 37 331


the minimal path sum from the top left to
the bottom right, by only moving to the right and down, is



131 → 201 → 96 → 342 → 746 → 422 → 121 → 37 → 331


and is equal to 2427.



Find the minimal path sum, in matrix.txt, a 31K text file containing a 80 by 80 matrix,
from the top left to the bottom right by only moving right and down.




I'm looking for feedback on a few specific aspects, but I appreciate general feedback and style suggestions as well. The raw code is available here. The program input is available here; the program needs to be run in the same folder as the input file.



The solution has two main parts:




  1. Reading a CSV file containing an 80x80 grid of integers into an array

  2. Traversing the array to accumulate the minimal path sum




{-|
file: p081.hs
title: Path sum: two ways
date: December 9, 2018

link: <https://projecteuler.net/problem=81>
-}

{-# LANGUAGE OverloadedStrings #-}

import Control.Arrow (first, (&&&), (***))
import Control.Monad (join, liftM, mapM)
import Data.Array (Array, Ix, array, bounds, (!))
import Data.Function (on)
import Data.Ix (inRange)
import Data.List (groupBy)
import Data.Maybe (fromJust)
import Data.Text (Text)
import qualified Data.Text as Text (lines, null, splitOn)
import qualified Data.Text.IO as TextIO (readFile)
import Data.Text.Read (decimal)

type Matrix a = Array (Int, Int) a

-- the shape of a matrix stored in a space-separated text file
textMatrixShape :: Text -> (Int, Int)
textMatrixShape = (length &&& length . Text.splitOn "," . head) . Text.lines

-- map over a monomorphic 2-tuple
mapTuple :: (a -> b) -> (a, a) -> (b, b)
mapTuple = join (***)

textMatrixBounds :: Text -> ((Int, Int), (Int, Int))
textMatrixBounds = (,) (0,0) . mapTuple (subtract 1) . textMatrixShape

-- from <https://hackage.haskell.org/package/either-5.0.1>
rightToMaybe :: Either a b -> Maybe b
rightToMaybe = either (const Nothing) Just

textMatrixElements :: Text -> Maybe [Int]
textMatrixElements = rightToMaybe
. fmap (map fst)
. mapM decimal
. concatMap (Text.splitOn ",")
. Text.lines

grid :: (Int, Int) -> [(Int, Int)]
grid (m, n) = [(i, j) | i <- [0..m - 1], j <- [0..n - 1]]

-- textMatrixAssocs :: Text -> Maybe [((Int, Int), Int)]
-- textMatrixAssocs t = liftM (zip ((grid . textMatrixShape) t)) (textMatrixElements t)

textMatrixAssocs :: Text -> Maybe [((Int, Int), Int)]
textMatrixAssocs = uncurry fmap . first zip
. (grid . textMatrixShape &&& textMatrixElements)

-- textMatrix :: Text -> Maybe (Matrix Int)
-- textMatrix t = liftM (array (textMatrixBounds t)) (textMatrixAssocs t)

textMatrix :: Text -> Maybe (Matrix Int)
textMatrix = uncurry fmap . first array . (textMatrixBounds &&& textMatrixAssocs)

rightAndDown :: Num a => Matrix a -> ((Int, Int), a) -> [((Int, Int), a)]
rightAndDown m (i, s) = [(i', s + m ! i')
| i' <- [fmap (+ 1) i, first (+ 1) i]
, inRange (bounds m) i']

-- | Blackbird combinator
(...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(...) = (.) . (.)
infix 8 ...

updateFrontier :: (Num a, Ord a) => Matrix a -> [((Int, Int), a)] -> [((Int, Int), a)]
updateFrontier = map minimum . groupBy ((==) `on` fst) ... concatMap . rightAndDown

minimalPathSum :: (Num a, Ord a) => Matrix a -> a
minimalPathSum m = go [((0, 0), m ! (0, 0))]
where
go f = case f' of
-> (minimum . map snd) f
_ -> go f'
where
f' = updateFrontier m f

p081 :: IO Int
p081 = do
t <- TextIO.readFile "p081_matrix.txt"
return (minimalPathSum . fromJust . textMatrix $ t)

main :: IO ()
main = do
print =<< p081


Questions



I tried to use a point-free style wherever I could. Are there more elegant ways to do this? Is it too obscure?



I used Text and Array for performance reasons. Are there any ways that I could further improve performance without re-writing the program?



In the first part, the file is read using Data.Text.IO.readFile. The shape of the text matrix is estimated using TextMatrixShape, which is used to determine the bounds of the array in TextMatrixBounds. This is not safe, as the number of elements in each line of the text file is not guaranteed to be the same in every line in general. Is there a better way to get the shape of the array?



The elements are extracted from the text file using textMatrixElements and converted into an association list in textMatrixAssocs. I'm worried that this might be an inefficient way to build an array, as the array appears to me to be traversed multiple times. I would greatly appreciate it if someone could shed some light on this.



What of my use of Maybe in my text* functions? Is this appropriate?



In textMatrixElements, I use the decimal reader from Data.Text.Read to convert text values into integers. Is there a nice way to make this function more polymorphic?



In the second part, I accumulate the minimum path sum to each point in a frontier, which is an association list of array indices and path sums. In rightAndDown, I construct a list of next moves from a frontier element. For every next move, I'm checking whether the index is in the bounds of the matrix m. Is this wasterful?



Note that I try to solve Project Euler problems without external dependencies, and I'm interested in learning how to do things in the general case, not just to solve this particular problem. I want to hardcode as little as possible.










share|improve this question




















  • 2




    Point free is cute, but only when it adds clarity. updateFrontier pushes that boundary.
    – Alex Reinking
    yesterday













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I just completed Project Euler Problem 81 in Haskell:




In the 5 by 5 matrix below,



131   673 234 103 18
201 96 342 965 150
630 803 746 422 111
537 699 497 121 956
805 732 524 37 331


the minimal path sum from the top left to
the bottom right, by only moving to the right and down, is



131 → 201 → 96 → 342 → 746 → 422 → 121 → 37 → 331


and is equal to 2427.



Find the minimal path sum, in matrix.txt, a 31K text file containing a 80 by 80 matrix,
from the top left to the bottom right by only moving right and down.




I'm looking for feedback on a few specific aspects, but I appreciate general feedback and style suggestions as well. The raw code is available here. The program input is available here; the program needs to be run in the same folder as the input file.



The solution has two main parts:




  1. Reading a CSV file containing an 80x80 grid of integers into an array

  2. Traversing the array to accumulate the minimal path sum




{-|
file: p081.hs
title: Path sum: two ways
date: December 9, 2018

link: <https://projecteuler.net/problem=81>
-}

{-# LANGUAGE OverloadedStrings #-}

import Control.Arrow (first, (&&&), (***))
import Control.Monad (join, liftM, mapM)
import Data.Array (Array, Ix, array, bounds, (!))
import Data.Function (on)
import Data.Ix (inRange)
import Data.List (groupBy)
import Data.Maybe (fromJust)
import Data.Text (Text)
import qualified Data.Text as Text (lines, null, splitOn)
import qualified Data.Text.IO as TextIO (readFile)
import Data.Text.Read (decimal)

type Matrix a = Array (Int, Int) a

-- the shape of a matrix stored in a space-separated text file
textMatrixShape :: Text -> (Int, Int)
textMatrixShape = (length &&& length . Text.splitOn "," . head) . Text.lines

-- map over a monomorphic 2-tuple
mapTuple :: (a -> b) -> (a, a) -> (b, b)
mapTuple = join (***)

textMatrixBounds :: Text -> ((Int, Int), (Int, Int))
textMatrixBounds = (,) (0,0) . mapTuple (subtract 1) . textMatrixShape

-- from <https://hackage.haskell.org/package/either-5.0.1>
rightToMaybe :: Either a b -> Maybe b
rightToMaybe = either (const Nothing) Just

textMatrixElements :: Text -> Maybe [Int]
textMatrixElements = rightToMaybe
. fmap (map fst)
. mapM decimal
. concatMap (Text.splitOn ",")
. Text.lines

grid :: (Int, Int) -> [(Int, Int)]
grid (m, n) = [(i, j) | i <- [0..m - 1], j <- [0..n - 1]]

-- textMatrixAssocs :: Text -> Maybe [((Int, Int), Int)]
-- textMatrixAssocs t = liftM (zip ((grid . textMatrixShape) t)) (textMatrixElements t)

textMatrixAssocs :: Text -> Maybe [((Int, Int), Int)]
textMatrixAssocs = uncurry fmap . first zip
. (grid . textMatrixShape &&& textMatrixElements)

-- textMatrix :: Text -> Maybe (Matrix Int)
-- textMatrix t = liftM (array (textMatrixBounds t)) (textMatrixAssocs t)

textMatrix :: Text -> Maybe (Matrix Int)
textMatrix = uncurry fmap . first array . (textMatrixBounds &&& textMatrixAssocs)

rightAndDown :: Num a => Matrix a -> ((Int, Int), a) -> [((Int, Int), a)]
rightAndDown m (i, s) = [(i', s + m ! i')
| i' <- [fmap (+ 1) i, first (+ 1) i]
, inRange (bounds m) i']

-- | Blackbird combinator
(...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(...) = (.) . (.)
infix 8 ...

updateFrontier :: (Num a, Ord a) => Matrix a -> [((Int, Int), a)] -> [((Int, Int), a)]
updateFrontier = map minimum . groupBy ((==) `on` fst) ... concatMap . rightAndDown

minimalPathSum :: (Num a, Ord a) => Matrix a -> a
minimalPathSum m = go [((0, 0), m ! (0, 0))]
where
go f = case f' of
-> (minimum . map snd) f
_ -> go f'
where
f' = updateFrontier m f

p081 :: IO Int
p081 = do
t <- TextIO.readFile "p081_matrix.txt"
return (minimalPathSum . fromJust . textMatrix $ t)

main :: IO ()
main = do
print =<< p081


Questions



I tried to use a point-free style wherever I could. Are there more elegant ways to do this? Is it too obscure?



I used Text and Array for performance reasons. Are there any ways that I could further improve performance without re-writing the program?



In the first part, the file is read using Data.Text.IO.readFile. The shape of the text matrix is estimated using TextMatrixShape, which is used to determine the bounds of the array in TextMatrixBounds. This is not safe, as the number of elements in each line of the text file is not guaranteed to be the same in every line in general. Is there a better way to get the shape of the array?



The elements are extracted from the text file using textMatrixElements and converted into an association list in textMatrixAssocs. I'm worried that this might be an inefficient way to build an array, as the array appears to me to be traversed multiple times. I would greatly appreciate it if someone could shed some light on this.



What of my use of Maybe in my text* functions? Is this appropriate?



In textMatrixElements, I use the decimal reader from Data.Text.Read to convert text values into integers. Is there a nice way to make this function more polymorphic?



In the second part, I accumulate the minimum path sum to each point in a frontier, which is an association list of array indices and path sums. In rightAndDown, I construct a list of next moves from a frontier element. For every next move, I'm checking whether the index is in the bounds of the matrix m. Is this wasterful?



Note that I try to solve Project Euler problems without external dependencies, and I'm interested in learning how to do things in the general case, not just to solve this particular problem. I want to hardcode as little as possible.










share|improve this question















I just completed Project Euler Problem 81 in Haskell:




In the 5 by 5 matrix below,



131   673 234 103 18
201 96 342 965 150
630 803 746 422 111
537 699 497 121 956
805 732 524 37 331


the minimal path sum from the top left to
the bottom right, by only moving to the right and down, is



131 → 201 → 96 → 342 → 746 → 422 → 121 → 37 → 331


and is equal to 2427.



Find the minimal path sum, in matrix.txt, a 31K text file containing a 80 by 80 matrix,
from the top left to the bottom right by only moving right and down.




I'm looking for feedback on a few specific aspects, but I appreciate general feedback and style suggestions as well. The raw code is available here. The program input is available here; the program needs to be run in the same folder as the input file.



The solution has two main parts:




  1. Reading a CSV file containing an 80x80 grid of integers into an array

  2. Traversing the array to accumulate the minimal path sum




{-|
file: p081.hs
title: Path sum: two ways
date: December 9, 2018

link: <https://projecteuler.net/problem=81>
-}

{-# LANGUAGE OverloadedStrings #-}

import Control.Arrow (first, (&&&), (***))
import Control.Monad (join, liftM, mapM)
import Data.Array (Array, Ix, array, bounds, (!))
import Data.Function (on)
import Data.Ix (inRange)
import Data.List (groupBy)
import Data.Maybe (fromJust)
import Data.Text (Text)
import qualified Data.Text as Text (lines, null, splitOn)
import qualified Data.Text.IO as TextIO (readFile)
import Data.Text.Read (decimal)

type Matrix a = Array (Int, Int) a

-- the shape of a matrix stored in a space-separated text file
textMatrixShape :: Text -> (Int, Int)
textMatrixShape = (length &&& length . Text.splitOn "," . head) . Text.lines

-- map over a monomorphic 2-tuple
mapTuple :: (a -> b) -> (a, a) -> (b, b)
mapTuple = join (***)

textMatrixBounds :: Text -> ((Int, Int), (Int, Int))
textMatrixBounds = (,) (0,0) . mapTuple (subtract 1) . textMatrixShape

-- from <https://hackage.haskell.org/package/either-5.0.1>
rightToMaybe :: Either a b -> Maybe b
rightToMaybe = either (const Nothing) Just

textMatrixElements :: Text -> Maybe [Int]
textMatrixElements = rightToMaybe
. fmap (map fst)
. mapM decimal
. concatMap (Text.splitOn ",")
. Text.lines

grid :: (Int, Int) -> [(Int, Int)]
grid (m, n) = [(i, j) | i <- [0..m - 1], j <- [0..n - 1]]

-- textMatrixAssocs :: Text -> Maybe [((Int, Int), Int)]
-- textMatrixAssocs t = liftM (zip ((grid . textMatrixShape) t)) (textMatrixElements t)

textMatrixAssocs :: Text -> Maybe [((Int, Int), Int)]
textMatrixAssocs = uncurry fmap . first zip
. (grid . textMatrixShape &&& textMatrixElements)

-- textMatrix :: Text -> Maybe (Matrix Int)
-- textMatrix t = liftM (array (textMatrixBounds t)) (textMatrixAssocs t)

textMatrix :: Text -> Maybe (Matrix Int)
textMatrix = uncurry fmap . first array . (textMatrixBounds &&& textMatrixAssocs)

rightAndDown :: Num a => Matrix a -> ((Int, Int), a) -> [((Int, Int), a)]
rightAndDown m (i, s) = [(i', s + m ! i')
| i' <- [fmap (+ 1) i, first (+ 1) i]
, inRange (bounds m) i']

-- | Blackbird combinator
(...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(...) = (.) . (.)
infix 8 ...

updateFrontier :: (Num a, Ord a) => Matrix a -> [((Int, Int), a)] -> [((Int, Int), a)]
updateFrontier = map minimum . groupBy ((==) `on` fst) ... concatMap . rightAndDown

minimalPathSum :: (Num a, Ord a) => Matrix a -> a
minimalPathSum m = go [((0, 0), m ! (0, 0))]
where
go f = case f' of
-> (minimum . map snd) f
_ -> go f'
where
f' = updateFrontier m f

p081 :: IO Int
p081 = do
t <- TextIO.readFile "p081_matrix.txt"
return (minimalPathSum . fromJust . textMatrix $ t)

main :: IO ()
main = do
print =<< p081


Questions



I tried to use a point-free style wherever I could. Are there more elegant ways to do this? Is it too obscure?



I used Text and Array for performance reasons. Are there any ways that I could further improve performance without re-writing the program?



In the first part, the file is read using Data.Text.IO.readFile. The shape of the text matrix is estimated using TextMatrixShape, which is used to determine the bounds of the array in TextMatrixBounds. This is not safe, as the number of elements in each line of the text file is not guaranteed to be the same in every line in general. Is there a better way to get the shape of the array?



The elements are extracted from the text file using textMatrixElements and converted into an association list in textMatrixAssocs. I'm worried that this might be an inefficient way to build an array, as the array appears to me to be traversed multiple times. I would greatly appreciate it if someone could shed some light on this.



What of my use of Maybe in my text* functions? Is this appropriate?



In textMatrixElements, I use the decimal reader from Data.Text.Read to convert text values into integers. Is there a nice way to make this function more polymorphic?



In the second part, I accumulate the minimum path sum to each point in a frontier, which is an association list of array indices and path sums. In rightAndDown, I construct a list of next moves from a frontier element. For every next move, I'm checking whether the index is in the bounds of the matrix m. Is this wasterful?



Note that I try to solve Project Euler problems without external dependencies, and I'm interested in learning how to do things in the general case, not just to solve this particular problem. I want to hardcode as little as possible.







programming-challenge array haskell graph pathfinding






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 17 hours ago









200_success

128k15149412




128k15149412










asked yesterday









castle-bravo

326210




326210








  • 2




    Point free is cute, but only when it adds clarity. updateFrontier pushes that boundary.
    – Alex Reinking
    yesterday














  • 2




    Point free is cute, but only when it adds clarity. updateFrontier pushes that boundary.
    – Alex Reinking
    yesterday








2




2




Point free is cute, but only when it adds clarity. updateFrontier pushes that boundary.
– Alex Reinking
yesterday




Point free is cute, but only when it adds clarity. updateFrontier pushes that boundary.
– Alex Reinking
yesterday















active

oldest

votes











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");

StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f209398%2fproject-euler-81-in-haskell-minimal-path-sum-through-a-matrix%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Code Review Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f209398%2fproject-euler-81-in-haskell-minimal-path-sum-through-a-matrix%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei