Problem 1049. Path of least resistance

Find the length of the shortest path through the matrix from the top left to bottom right corner. You may move right, down, or diagonally right-down one element at a time. The length of the path is the sum of the elements you pass through.

Thanks, Jean-Marie. This solution uses recursive calls of the function. So all elements of the matrix are processed.
If you would like to learn more about functional programming principles, I recommend 'Functional Programming Principles in Scala' course by Martin Odersky at Coursera. It starts soon. Actually, I wrote this solution after taking the course a year ago. It is very interesting to look at the same problem from different points of view.