Add unchecked day4pt1, `part` lib functions
authorJack Kinsey <kinsey_john@bah.com>
Wed, 4 Dec 2019 15:54:56 +0000 (10:54 -0500)
committerJack Kinsey <kinsey_john@bah.com>
Wed, 4 Dec 2019 15:54:56 +0000 (10:54 -0500)
src/adventofcode2019/day04.clj [new file with mode: 0644]
src/adventofcode2019/lib.clj

diff --git a/src/adventofcode2019/day04.clj b/src/adventofcode2019/day04.clj
new file mode 100644 (file)
index 0000000..0c5c08d
--- /dev/null
@@ -0,0 +1,18 @@
+(ns adventofcode2019.day04
+    [:require [adventofcode2019.lib :refer :all]
+              [clojure.string :as str]
+              [clojure.math.combinatorics :as combo]])
+
+(defn find-passwords [low high]
+  (let [dupe-digits #(some (partial apply =) (partition 2 1 %))
+        increasing (partial apply <=)
+        to-digits #(map int (str %))]
+   (->> (range low (inc high))
+        (map to-digits)
+        (filter (every-pred dupe-digits increasing)))))
+
+(defn day04 []
+  (let [[low high] [0 1]
+        passwords (find-passwords low high)] 
+    (part1 (count passwords))
+    #_(part2 nil)))
index e84621639e655f385ba0158994ec687a60fdb613..834893c31815f6ccd28447ef4cc3f1d1ccec7b0d 100644 (file)
@@ -14,3 +14,8 @@
 
 (def parse-int
   #(Integer/parseInt %))
+
+(def part1 
+  #(println (str "Part 1: " %)))
+(def part2 
+  #(println (str "Part 2: " %)))