Clojure:
(utils/read-file just slurps and splits by newlines)
utils/read-file
Part 1:
(->> (utils/read-file (str utils/resources-path "day1.txt")) (map #(Integer. ^String %)) (apply +))
Part 2:
(->> (utils/read-file (str utils/resources-path "day1.txt")) (map #(Integer. ^String %)) (cycle) (reduce (fn [{:keys [freq seen]} freq-change] (if (seen freq) (reduced freq) {:freq (+ freq freq-change) :seen (conj seen freq)})) {:freq 0 :seen #{}}))
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Clojure:
(
utils/read-file
just slurps and splits by newlines)Part 1:
Part 2: