Non-LINQ solution to problem 28

Runs in around 0.0008s for a 1001 x 1001 grid.