Skip to content

Instantly share code, notes, and snippets.

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