-
-
Save pieter-van-prooijen/2c7136ce1f581f4cbc3c78de5b4ea25b to your computer and use it in GitHub Desktop.
Advent of Clojure solutions
This file contains hidden or 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 adventofcode2015.core) | |
(defn step [[row column value]] | |
(let [new-value (mod (* value 252533) 33554393) | |
max-depth (dec (+ row column)) | |
new-row (if (= column max-depth) (inc max-depth) (dec row)) | |
new-column (if (= column max-depth) 1 (inc column))] | |
[new-row new-column new-value])) | |
(def initial [1 1 20151125]) | |
(->> (iterate step initial) | |
(filter (fn [[row column _ _]] | |
(and (= row 3010) (= column 3019))) ) | |
(first)) | |
(comment (defn index [row column] | |
(- (reduce + (range (+ row column))) (dec row)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment