Skip to content

Instantly share code, notes, and snippets.

@hroi
Created March 21, 2010 01:08
Show Gist options
  • Select an option

  • Save hroi/339008 to your computer and use it in GitHub Desktop.

Select an option

Save hroi/339008 to your computer and use it in GitHub Desktop.
; 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