Last active
March 9, 2017 22:49
-
-
Save murasesyuka/d1a156fc97d13d104d4dc45d24c4ff94 to your computer and use it in GitHub Desktop.
Successfully set matrix of OCaml
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
| module DP = | |
| struct | |
| let h = 13 | |
| let w = 17 | |
| (* let memo = Array.make (h+1) (Array.make (w+1) 0) *) | |
| let memo = Array.make_matrix (h+1) (w+1) 0 | |
| let rec dfs nowh noww = | |
| if nowh > h || noww > w then | |
| 0 | |
| else if nowh = h && noww = w then | |
| 1 | |
| else if memo.(nowh).(noww) <> 0 then memo.(nowh).(noww) | |
| else begin | |
| memo.(nowh).(noww) <- ((dfs (nowh+1) noww) + (dfs nowh (noww+1))); | |
| memo.(nowh).(noww) | |
| end | |
| end | |
| let () = Printf.printf "hello %d" (DP.dfs 0 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment