From: Jack Kinsey Date: Thu, 5 Dec 2019 00:44:39 +0000 (-0500) Subject: Test day4pt1 and add correct day4pt2 X-Git-Url: http://git.jkinsey.net/?p=adventofcode2019.git;a=commitdiff_plain;h=b49567e7f99c079675b87a29681bafe5cf834e1e Test day4pt1 and add correct day4pt2 --- diff --git a/src/adventofcode2019/core.clj b/src/adventofcode2019/core.clj index 68320b9..fb1a320 100644 --- a/src/adventofcode2019/core.clj +++ b/src/adventofcode2019/core.clj @@ -1,5 +1,6 @@ (ns adventofcode2019.core - [:require (adventofcode2019 day01 day02 day03)]) + [:require (adventofcode2019 day01 day02 day03 + day04)]) (defn -main ([] diff --git a/src/adventofcode2019/day04.clj b/src/adventofcode2019/day04.clj index 0c5c08d..0129398 100644 --- a/src/adventofcode2019/day04.clj +++ b/src/adventofcode2019/day04.clj @@ -12,7 +12,9 @@ (filter (every-pred dupe-digits increasing))))) (defn day04 [] - (let [[low high] [0 1] - passwords (find-passwords low high)] + (let [[low high] [307237 769058] + passwords (find-passwords low high) + strict-dd (fn [x] (some #(= (count %) 2) + (partition-by identity x)))] (part1 (count passwords)) - #_(part2 nil))) + (part2 (count (filter strict-dd passwords)))))