From: Jack Kinsey Date: Fri, 13 Dec 2019 18:52:51 +0000 (-0500) Subject: Add untested day13pt1 X-Git-Url: http://git.jkinsey.net/?a=commitdiff_plain;h=15f6c3bbb172e88ff9a6d393057abc40db9373bf;p=adventofcode2019.git Add untested day13pt1 --- diff --git a/src/adventofcode2019/core.clj b/src/adventofcode2019/core.clj index c2d5b25..ca8684b 100644 --- a/src/adventofcode2019/core.clj +++ b/src/adventofcode2019/core.clj @@ -1,7 +1,7 @@ (ns adventofcode2019.core [:require (adventofcode2019 day01 day02 day03 day04 day05 day06 day07 day08 day09 day10 - day11 day12)]) + day11 day12 day13)]) (defn -main ([] diff --git a/src/adventofcode2019/day13.clj b/src/adventofcode2019/day13.clj new file mode 100644 index 0000000..759b3b3 --- /dev/null +++ b/src/adventofcode2019/day13.clj @@ -0,0 +1,14 @@ +(ns adventofcode2019.day13 + [:require [adventofcode2019.lib :refer :all] + [adventofcode2019.intcode :as i] + [clojure.string :as str] + [clojure.core.match :refer [match]] + [clojure.math.combinatorics :as combo]]) + +(defn day13 [] + (let [input (i/get-program (input-file)) + output (:output (i/intcode (i/build-state input))) + draw-tiles (fn [screen [x y t]] (assoc screen [x y] t)) + screen (reduce draw-tiles {} (partition 3 output))] + (part1 (count (filter #(= % 4) (vals screen)))) + #_(part2))) diff --git a/src/adventofcode2019/intcode.clj b/src/adventofcode2019/intcode.clj index 84a9625..9f09f10 100644 --- a/src/adventofcode2019/intcode.clj +++ b/src/adventofcode2019/intcode.clj @@ -61,6 +61,9 @@ args (map memory [(+ 1 ctr) (+ 2 ctr) (+ 3 ctr)])] (apply operation state args))) +(defn get-program [input-file] + (map parse-int (get-list-from-file input-file) #",")) + (defn build-state ([program] (let [memory (into {} (map-indexed #(vector %1 %2) program))]