Created
December 4, 2017 23:30
-
-
Save tosh/25e01f7d5b7af2016ca3bfb781e96ea0 to your computer and use it in GitHub Desktop.
advent-of-code-2017-day4.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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