Add untested day13pt1
authorJack Kinsey <kinsey_john@bah.com>
Fri, 13 Dec 2019 18:52:51 +0000 (13:52 -0500)
committerJack Kinsey <kinsey_john@bah.com>
Fri, 13 Dec 2019 18:52:51 +0000 (13:52 -0500)
src/adventofcode2019/core.clj
src/adventofcode2019/day13.clj [new file with mode: 0644]
src/adventofcode2019/intcode.clj

index c2d5b25cc72d988e847ee56f2715cd973155af8f..ca8684be0c2f8b0daecc24c44455ffc771463a9c 100644 (file)
@@ -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 (file)
index 0000000..759b3b3
--- /dev/null
@@ -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)))
index 84a96254126ed52d7dcbb53c4e8c808be06aced9..9f09f1083f4a9fcff5c7e3f2994fdc86abdf2017 100644 (file)
@@ -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))]