Created
March 21, 2010 01:08
-
-
Save hroi/339008 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
| ; Problem 15 | |
| ; Starting in the top left corner of a 22 grid, there are 6 | |
| ; routes (without backtracking) to the bottom right corner. | |
| ; | |
| ; How many routes are there through a 2020 grid? | |
| ; | |
| (def facts (lazy-cat [1] (map * facts (rest natnums)))) | |
| (defn solve [gridsize] | |
| (let [gz (dec gridsize)] | |
| (/ (nth facts (+ gz gridsize)) | |
| (* (nth facts gz) | |
| (nth facts gz))))) | |
| (def answer (solve 20)) | |
| ; => 137846528820 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment