Created
December 4, 2017 15:56
-
-
Save Arnot/bede87e482a35a5a3913c80e33111888 to your computer and use it in GitHub Desktop.
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
(defun aoc-day4-1 (input) | |
(let ((num-correct-passphrases 0)) | |
(dolist (passphrase input) | |
(let ((words (split-string passphrase " "))) | |
(when (= (length words) | |
(length (delete-dups words))) | |
(incf num-correct-passphrases)))) | |
num-correct-passphrases)) | |
(defun aoc-sort-string (str) | |
(apply #'string (sort (string-to-list str) #'<))) | |
(defun aoc-day4-2 (input) | |
(let ((num-correct-passphrases 0)) | |
(dolist (passphrase input) | |
(let ((words (mapcar #'aoc-sort-string (split-string passphrase " ")))) | |
(when (= (length words) | |
(length (delete-dups words))) | |
(incf num-correct-passphrases)))) | |
num-correct-passphrases)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment