Created
October 18, 2012 15:04
-
-
Save otf/3912414 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec move (x, y) r g n = | |
if x < 0 || y < 0 || x > g || y > g then n | |
elif (x,y) = (g, g) then n + 1 | |
else match List.tryFind ((=) (x, y)) r with | |
| Some _ -> n | |
| None -> | |
[(x + 1, y); (x, y + 1); (x - 1, y); (x, y - 1)] | |
|> List.map (fun xy -> move xy ((x, y)::r) g) | |
|> List.fold (|>) n | |
[<EntryPoint>] | |
let main argv = | |
let grids = int argv.[0] | |
printfn "%A" (move (0,0) [] grids 0) | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment