(ns edition2022.day6)
(defn read-in []
(seq (slurp "resources/day6.in")))
(defn unique? [marker]
(let [expected-size (count marker)
s (set marker)]
(= expected-size (count s))))
(defn find-idx-after-marker [marker-size datastream]
(->> (partition marker-size 1 datastream)
(take-while #(not (unique? %)))
(count)
(+ marker-size)))
(comment
(find-idx-after-marker 4 [\a \b \c \d \e])
(find-idx-after-marker 4 (seq "bvwbjplbgvbhsrlpgdmjqwftvncz"))
(find-idx-after-marker 4 (seq "nppdvjthqldpwncqszvftbrmjlhg"))
(unique? [\a \b \c \d])
(find-idx-after-marker 4 (read-in))
(find-idx-after-marker 14 (read-in))
(find-idx-after-marker 14 (seq "mjqjpqmgbljsphdztnvjfqwrcgsmlb"))
)