minimal-path-sum-to ( x y matrix -- n )


Vocabulary
project-euler.081.private

Inputs
xan object
yan object
matrixan object


Outputs
nan object


Definition


:: minimal-path-sum-to ( x y matrix -- n )
x y + zero?
[ 0 ] [
x zero?
[ 0 y 1 - matrix get-matrix ] [
y zero?
[ x 1 - 0 matrix get-matrix ] [
x 1 - y matrix get-matrix x y 1 -
matrix get-matrix min
] if
] if
] if ;