45 lines
866 B
Haskell
45 lines
866 B
Haskell
{-
|
|
https://projecteuler.net/problem=15
|
|
|
|
Starting in the top left corner of a 2x2 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 20x20 grid?
|
|
-}
|
|
module Main where
|
|
|
|
import Prelude hiding (Right)
|
|
|
|
main :: IO ()
|
|
main = print ans
|
|
|
|
ans = 42
|
|
|
|
limit = 2
|
|
points = [ (x,y)
|
|
| x <- [0..limit]
|
|
, y <- [0..limit]
|
|
]
|
|
|
|
data Direction = Right | Down
|
|
|
|
move Right (x,y) = (x+1, y )
|
|
move Down (x,y) = (x , y+1)
|
|
|
|
-- solve :: (Int, Int) -> [[(Int, Int)]]
|
|
{-
|
|
λ> [(0,0)]
|
|
[(0,0)]
|
|
λ> [(0,0),(1,0),(2,0),(2,1),(2,2)]
|
|
[(0,0),(1,0),(2,0),(2,1),(2,2)]
|
|
λ> [ [(0,0),(1,0),(2,0),(2,1),(2,2)], [(0,0),(1,0),(1,1),(2,1),(2,2)]]
|
|
[[(0,0),(1,0),(2,0),(2,1),(2,2)],[(0,0),(1,0),(1,1),(2,1),(2,2)]]
|
|
λ>
|
|
-}
|
|
|
|
data Tree a
|
|
= Leaf a
|
|
| Branch (Tree a) (Tree a)
|
|
deriving (Show)
|
|
|
|
|