Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn has-n? [word n]
- (some #(= n %) (vals (frequencies word))))
- (defn off-by-1? [[a b]]
- (->> (map vector a b)
- (filter (fn [[x y]] (not= x y)))
- ((fn [lst] (= 1 (count lst))))))
- (defn part1 []
- (* (count (filter #(has-n? % 2) input))
- (count (filter #(has-n? % 3) input))))
- (defn part2 []
- (->> (for [x input y input] (vector x y))
- (filter off-by-1?)
- (first)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement