Skip to content

Instantly share code, notes, and snippets.

@Heliosmaster
Forked from skuro/forkme.md
Last active December 12, 2018 19:34
Show Gist options
  • Save Heliosmaster/35652bc9b373da95d4f76f597c8617b8 to your computer and use it in GitHub Desktop.
Save Heliosmaster/35652bc9b373da95d4f76f597c8617b8 to your computer and use it in GitHub Desktop.
Advent of Clojure solutions
(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