I still can't get past part 2 of Day 1. Lol! Yeesh. I was hoping I would be farther along in my skills by this point. Ok, hopefully this shows what I'm trying to get at:
(defn part2 [data]
(loop [seen #{}
freq 0]
(if (contains? seen freq)
freq
(let [seen (conj seen freq)
freq (reduce + (cycle data))]
(recur seen freq)))))
I figure I have to keep a running tally of frequencies and then compare the current frequency to that. That made me think I probably want a set right because it can't have any repeats. Now that I write it out though, not sure that will be necessary. But something isn't working in my else clause (obviously the meat of the function). Any tips on where I'm going wrong here.
(defn first-duplicate
([l] (first-duplicate l #{}))
([l seen]
(let [[head & tail] l]
(if (contains? seen head)
head
(recur tail (conj seen head))))))
make a function that does what you need. here's a simple loop until it gets something already seenthank you. I'll try and process this. Reflecting on the process, I'm realizing I just have a vague notion of some of these concepts and then just blindly flailing about it in the repl.
@chase-lambert I did a version of your approach here: https://github.com/potetm/advent-of-code/blob/master/src/advent_2018/day_1.clj#L32
You can watch the vid here: https://potetm.com/video/aoc-2018-d01.html