We store a matrix of integers in a file by putting each row on a separate
line, and separating all integers on a row by spaces. Your task is to find
the length of a longest path in a rectangular city:
- Write a function longest_path that takes two locations
of text files: i) a file containing an $$m \times (n + 1)$$ matrix Down
and ii) a file containing an $$(m + 1) \times n$$ Right. The
function must return the length of a longest path from source $$(0, 0)$$
to sink $$(m, n)$$ in the $$(m + 1) \times (n + 1)$$ rectangular grid whose edges
are defined by the matrices Down and Right.
Example
In the following interactive session, we assume the text files down01.txt and right01.txt to be located
in the current directory.
>>> longest_path('down01.txt', 'right01.txt')
34