Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.Array
- solve :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Integer
- solve n m x y x0 y0 k = table ! (x, y, k) where
- bnds = ((0, 0, 0), (n, m, k))
- table = listArray bnds . map solve' $ range bnds
- safeTable x y k
- | x >= 0 && y >= 0 && x < n && y < m = table ! (x, y, k)
- | otherwise = 0
- solve' (x, y, k)
- | k == 0 = if (x == x0 && y == y0) then 1 else 0
- | otherwise = (safeTable x (y+1) (k-1)) + (safeTable x (y-1) (k-1)) + (safeTable (x-1) y (k-1)) + (safeTable (x+1) y (k-1))
- main = print (solve 100 100 50 50 60 60 200)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement