From 0503903a720cb612de17b626ee38e802539fde3c Mon Sep 17 00:00:00 2001 From: Jack Kinsey Date: Wed, 4 Dec 2019 10:54:56 -0500 Subject: [PATCH] Add unchecked day4pt1, `part` lib functions --- src/adventofcode2019/day04.clj | 18 ++++++++++++++++++ src/adventofcode2019/lib.clj | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 src/adventofcode2019/day04.clj diff --git a/src/adventofcode2019/day04.clj b/src/adventofcode2019/day04.clj new file mode 100644 index 0000000..0c5c08d --- /dev/null +++ b/src/adventofcode2019/day04.clj @@ -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))) diff --git a/src/adventofcode2019/lib.clj b/src/adventofcode2019/lib.clj index e846216..834893c 100644 --- a/src/adventofcode2019/lib.clj +++ b/src/adventofcode2019/lib.clj @@ -14,3 +14,8 @@ (def parse-int #(Integer/parseInt %)) + +(def part1 + #(println (str "Part 1: " %))) +(def part2 + #(println (str "Part 2: " %))) -- 2.26.2