Problem 6:
Square Path
Given a square of positive integers input through stdin,
find the smallest sum of integers going from the top row
of the square to the bottom row while only going down, right,
or left. The square will be specified on n+1 lines of
input, where n is the side of the square. The first
line will contain the width of the square.
For example, given the input:
4
1 2 3 2
4 5 6 1
7 8 1 1
8 2 3 5
your program should print out 8, since the optimal
path starts at the top right, goes down, down, left
and down, giving the sum:
2+1+1+1+3 = 8
handin acmjudge prog6