Fork me on GitHub

so I solved part 1 of day 2 but it looks kind of hacky to me. Any suggestions?

(def data
  (->> (slurp "resources/y2018.d02.txt")

(defn double-letter? [s]
  (some #(= 2 %) (vals (frequencies s))))

(defn num-of-doubles [coll]
  (get (frequencies (map double-letter? coll)) true))

(defn triple-letter? [s]
  (some #(= 3 %) (vals (frequencies s))))

(defn num-of-triples [coll]
  (get (frequencies (map triple-letter? coll)) true))

(defn part1 [coll]
  (* (num-of-doubles coll) (num-of-triples coll)))

(part1 data)
;; => 6200


and I'm struggling with part 2 again. I remember doing this simple spellchecker tutorial: so was thinking this "levenshtein distance" could get me there. It's not working though as even the first string is saying it has a match with a 0 distance. But that isn't right. But now I can't get my brain off this strategy! If it continues to elude me I'll check out @potetm's video and other people's solutions. I'm thinking part 2's are going to be a bit outside my current ability but not sure when to call it and try to learn from others or keep fighting it. I don't know if spending days on one solution is fruitful at my level.


I remember I started with Levenshtein distance too but that was really slow


I implemented what the question asked for directly


Compare two strings character by character 😉


that's actually been one of my fears. I actually technically solve a problem but don't realize it's so inefficient that I gave up on it too soon.


And I sometimes spent like more than a work day on an exercise


but then maybe i should keep searching for a better solution anyways right? I think I read all problems should be able to be solved in less than 15 seconds or something.


Good to push yourself but if you get frustrated look for a hint 🙂


Or walk away for a bit


yeah, i do take long walks. my version of "hammock" time


i'll mull over your approach about comparing two strings character by character. thanks