-
-
Save Heliosmaster/35652bc9b373da95d4f76f597c8617b8 to your computer and use it in GitHub Desktop.
Advent of Clojure solutions
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
(ns adventclj.core) | |
;; By Samuel McHugh and Davide Taviani | |
(defn compute-next [prev] | |
(-> prev | |
(* 252533) | |
(rem 33554393))) | |
(defn index [r c] | |
(-> (* c c) | |
(- c) | |
(+ (* r r)) | |
(- (* 3 r)) | |
(/ 2) | |
(+ (* r c)) | |
inc) | |
) | |
(defn solution [row column] | |
(last (take (index row column) | |
(iterate compute-next 20151125)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment