Project Euler 15 with dynamic programming