-- Starting in the top left corner of a 2×2 grid, and only being able to move -- to the right and down, there are exactly 6 routes to the bottom right corner. -- How many such routes are there through a 20×20 grid? import Data.Array routesFrom = array ((0,0),(20,20)) $ [ ((row,20), 1) | row <- [0..20] ] ++ [ ((20,col), 1) | col <- [0..19] ] ++ [ ((row, col), (routesFrom!(row+1,col)) + (routesFrom!(row,col+1))) | row <- [0..19], col <- [0..19] ] main = print $ routesFrom ! (0,0)