Skip to content

Instantly share code, notes, and snippets.

@Arnot
Created December 4, 2017 15:56
Show Gist options
  • Save Arnot/bede87e482a35a5a3913c80e33111888 to your computer and use it in GitHub Desktop.
Save Arnot/bede87e482a35a5a3913c80e33111888 to your computer and use it in GitHub Desktop.
(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