]> localhost Git - adventofcode2019.git/blame - src/adventofcode2019/day16.clj
Add broken day13pt2
[adventofcode2019.git] / src / adventofcode2019 / day16.clj
CommitLineData
21ab31d9
JK
1(ns adventofcode2019.day16
2 [:require [adventofcode2019.lib :refer :all]
3 [clojure.string :as str]])
4
5(defn parse-input [input]
6 (map (comp parse-int str) input))
7
8(defn phase [input]
9 (let [pattern (fn [n]
10 (->> [0 1 0 -1]
11 (mapcat (partial repeat n))
12 (cycle)
13 (rest)))
14 transform (fn [i n]
15 (->> (map * input (pattern (inc i)))
16 (reduce +)
17 (str)
18 (last)
19 (str)
20 (parse-int)))]
21 (map-indexed transform input)))
22
23(defn result-of [input]
24 (as-> (parse-input input) it
25 (iterate phase it)
26 (nth it 100)
27 (take 8 it)
28 (str/join it)))
29
30(defn day16 []
31 (let [[input] (get-list-from-file (input-file))]
32 (part1 (result-of input))
33 #_(part2)))