Skip to content

Instantly share code, notes, and snippets.

@remvee
Forked from skuro/forkme.md
Created December 12, 2018 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remvee/7abd5d18d46571f1868446d2a67a9188 to your computer and use it in GitHub Desktop.
Save remvee/7abd5d18d46571f1868446d2a67a9188 to your computer and use it in GitHub Desktop.
Advent of Clojure solutions
(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