X-Git-Url: http://git.jkinsey.net/?p=adventofcode2019.git;a=blobdiff_plain;f=src%2Fadventofcode2019%2Fday16.clj;fp=src%2Fadventofcode2019%2Fday16.clj;h=0e4bc6e1510edb6a20da852e744ce3ba103f2c9a;hp=04d6714636da5e79938305e86fead68c91998a86;hb=3e681c731e0ca1e70e8c3a0e3dddfc2f2c442ed0;hpb=ab32e54381280135a0df771d293438c195259dc2 diff --git a/src/adventofcode2019/day16.clj b/src/adventofcode2019/day16.clj index 04d6714..0e4bc6e 100644 --- a/src/adventofcode2019/day16.clj +++ b/src/adventofcode2019/day16.clj @@ -20,14 +20,26 @@ (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)) - #_(part2))) + (part2 (fft input))))