Created
January 3, 2018 18:14
-
-
Save Romain-P/ec37cab7d9150f9669221cb2cf657088 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
| static int pyramid_path_alt(int size, int **map, int x, int y) | |
| { | |
| if (y == size - 1) | |
| return (map[y][x]); | |
| int a = pyramid_path_alt(size, map, x, y + 1); | |
| int b = pyramid_path_alt(size, map, x + 1, y + 1); | |
| int choosen = a < b ? a : b; | |
| return (map[y][x] + choosen); | |
| } | |
| int pyramid_path(int size, int **map) | |
| { | |
| return (pyramid_path_alt(size, map, 0, 0)); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment