-
-
Save remvee/7abd5d18d46571f1868446d2a67a9188 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 adv.code) | |
(defn lookup-seq [x i] | |
(lazy-seq (cons x (lookup-seq (+ i x) (inc i))))) | |
(defn lookup [x y] | |
(let [start (nth (lookup-seq 1 1) (dec y))] | |
(nth (lookup-seq start (inc y)) (dec x)))) | |
(defn val-seq [v] | |
(lazy-seq (cons v (val-seq (rem (* v 252533) 33554393))))) | |
(defn solution [x y] | |
(nth (val-seq 20151125) (dec (lookup x y)))) | |
(solution 3019 3010) ;; => 8997277 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment