This commit is contained in:
Adam Jeniski 2024-12-02 01:21:43 -05:00
parent 1f5cc1cf5e
commit 3e35bcad4a
2 changed files with 1026 additions and 7 deletions

1000
2024/input/2.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,15 +2,34 @@
(:require
[input-manager :refer [get-input]]
[core :as c]))
(do
(def input
(->> (get-input 1)
(map identity)))
input)
(def input (->> (get-input 2)
(map c/split-whitespace)
(map #(mapv parse-long %))))
(defn get-diffs [coll]
(->> (map vector coll (rest coll))
(mapv #(apply - %))))
(defn small-diffs? [diffs]
(or (every? #(<= 1 % 3) diffs)
(every? #(<= -3 % -1) diffs)))
(defn remove-at-idx [v idx]
(concat (subvec v 0 idx) (subvec v (inc idx))))
;; part 1
(->> input)
(->> input
(mapv get-diffs)
(filterv small-diffs?)
count)
;; part 2
;; (->> input)
(->> input
(map (fn [coll]
(map #(remove-at-idx coll %)
(range (count coll)))))
(map #(map get-diffs %))
(filter #(some small-diffs? %))
count)