Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun read-lines (filename)
- (with-open-file (in filename)
- (loop as line = (read-line in nil) while line collect line)))
- (defun anagram-p (w1 w2)
- (equal (sort (subseq w1 0) #'char<) (sort (subseq w2 0) #'char<)))
- (defun unscramble (word wordlist)
- (loop for i in wordlist if (anagram-p word i) return i))
- (let ((wordlist (read-lines "wordlist"))
- (words (read-lines "words")))
- (dolist (i words)
- (format t "~a -> ~a~%" i (unscramble i wordlist))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement