Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn has-n? [word n]
  2.   (some #(= n %) (vals (frequencies word))))
  3.  
  4. (defn off-by-1? [[a b]]
  5.   (->> (map vector a b)
  6.        (filter (fn [[x y]] (not= x y)))
  7.        ((fn [lst] (= 1 (count lst))))))
  8.  
  9. (defn part1 []
  10.   (* (count (filter #(has-n? % 2) input))
  11.      (count (filter #(has-n? % 3) input))))
  12.  
  13. (defn part2 []
  14.   (->> (for [x input y input] (vector x y))
  15.        (filter off-by-1?)
  16.        (first)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement