Skip to content

Instantly share code, notes, and snippets.

@tosh
Created December 4, 2017 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tosh/25e01f7d5b7af2016ca3bfb781e96ea0 to your computer and use it in GitHub Desktop.
Save tosh/25e01f7d5b7af2016ca3bfb781e96ea0 to your computer and use it in GitHub Desktop.
advent-of-code-2017-day4.cljs
(defn input [r]
(->> (.split r "\n")
(map #(.trim %))
(map #(.split % " "))))
(defn anagram? [a b]
(= (frequencies a)
(frequencies b)))
(defn valid? [passphrase]
(= (count passphrase)
(count (set passphrase))))
(defn valid2? [passphrase]
(let [frs (map frequencies passphrase)]
(= (count (distinct frs))
(count frs))))
(defn solve []
(->> (input raw-input)
(filter valid2?)
count))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment