just a note, the is a substring function called subs.
@henrymhp Жыл бұрын
Nice solution! Sharing a different one here, leveraging `partition` and the fact that sets are distinct by definition: (defn find-marker [l payload] (->> payload (partition l 1) (map-indexed vector) (filter #(= (count (set (second %))) l)) ffirst (+ l))) (find-marker 4 (slurp "./day_06.txt"))
@salim444 Жыл бұрын
nice, didn't think of using map-indexed and the lazy behavior of filter make this code performant
@MartinClausen Жыл бұрын
I came up with this: (->> (slurp "resources/input6.txt") (partition 4 1) (take-while #(apply (complement distinct?) %)) count (+ 4))