While the implementation is (probably) technically correct, it's not
efficient enough. Clearly something is going on here with optimization.
(parse-int)))]
(map-indexed transform input)))
(parse-int)))]
(map-indexed transform input)))
-(defn result-of [input]
- (as-> (parse-input input) it
- (iterate phase it)
- (nth it 100)
- (take 8 it)
- (str/join it)))
+(defn result-of
+ ([input]
+ (result-of 0 input))
+ ([offset input]
+ (as-> (parse-input input) it
+ (iterate phase it)
+ (nth it 100)
+ (drop offset it)
+ (take 8 it)
+ (str/join it))))
+
+(defn fft [input]
+ (->> (repeat 10000 input)
+ (str/join)
+ (result-of (->> input
+ (take 7)
+ (str/join)
+ (parse-int)))))
(defn day16 []
(let [[input] (get-list-from-file (input-file))]
(part1 (result-of input))
(defn day16 []
(let [[input] (get-list-from-file (input-file))]
(part1 (result-of input))
(:require [clojure.test :refer :all]
[adventofcode2019.day16 :refer :all]))
(:require [clojure.test :refer :all]
[adventofcode2019.day16 :refer :all]))
(is (= "24176176" (result-of "80871224585914546619083218645595")))
(is (= "73745418" (result-of "19617804207202209144916044189917")))
(is (= "52432133" (result-of "69317163492948606335995924319873"))))
(is (= "24176176" (result-of "80871224585914546619083218645595")))
(is (= "73745418" (result-of "19617804207202209144916044189917")))
(is (= "52432133" (result-of "69317163492948606335995924319873"))))
+
+(deftest examples-part2
+ #_(is (= "84462026" (fft "03036732577212944063491565474664")))
+ #_(is (= "78725270" (fft "02935109699940807407585447034323")))
+ #_(is (= "53553731" (fft "03081770884921959731165446850517"))))