Created
November 20, 2018 07:56
-
-
Save rand00/523371b0697a39293333a53389c42873 to your computer and use it in GitHub Desktop.
project euler no. 15
This file contains 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 combinations combine l l' = | |
CCList.cartesian_product [l; l'] | |
|> CCList.map (fun [p; p'] -> combine p p') | |
let paths xmax ymax = | |
let rec aux x y prev_paths = | |
if x > xmax || y > ymax then [] | |
else if x = xmax && y = ymax then prev_paths | |
else | |
let next_paths = List.flatten [ | |
aux (x+1) y [[ `Right ]]; | |
aux x (y+1) [[ `Down ]]; | |
] in | |
combinations (@) prev_paths next_paths | |
in | |
aux 0 0 [[]] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment