diff options
author | Andinus <andinus@nand.sh> | 2021-08-11 15:26:15 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-08-11 15:26:15 +0530 |
commit | 321825828ac918bad28d0597a8616c6dc9802c3c (patch) | |
tree | 0b8e9cb1012197750eb58e972736319b2a6abac2 /emacs-lisp/anagram | |
parent | 2979ef790ac5b8f58495e0dd08cafd6a3a2e30a5 (diff) | |
download | exercism-321825828ac918bad28d0597a8616c6dc9802c3c.tar.gz |
Add solved exercises
Diffstat (limited to 'emacs-lisp/anagram')
-rw-r--r-- | emacs-lisp/anagram/README.md | 13 | ||||
-rw-r--r-- | emacs-lisp/anagram/anagram-test.el | 54 | ||||
-rw-r--r-- | emacs-lisp/anagram/anagram.el | 14 |
3 files changed, 81 insertions, 0 deletions
diff --git a/emacs-lisp/anagram/README.md b/emacs-lisp/anagram/README.md new file mode 100644 index 0000000..88d0118 --- /dev/null +++ b/emacs-lisp/anagram/README.md @@ -0,0 +1,13 @@ +# Anagram + +Given a word and a list of possible anagrams, select the correct sublist. + +Given `"listen"` and a list of candidates like `"enlists" "google" +"inlets" "banana"` the program should return a list containing +`"inlets"`. +## Source + +Inspired by the Extreme Startup game [https://github.com/rchatley/extreme_startup](https://github.com/rchatley/extreme_startup) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/emacs-lisp/anagram/anagram-test.el b/emacs-lisp/anagram/anagram-test.el new file mode 100644 index 0000000..1fa4a94 --- /dev/null +++ b/emacs-lisp/anagram/anagram-test.el @@ -0,0 +1,54 @@ +;;; anagram-test.el --- Tests for Anagram (exercism) + +;;; Commentary: + +;;; Code: + +(load-file "anagram.el") + +(ert-deftest no-matches () + (should (equal '() (anagrams-for + "diaper" + '("hello" "world" "zombies" "pants"))))) + +(ert-deftest detect-simple-anagram () + (should (equal '("tan") (anagrams-for + "ant" + '("tan" "stand" "at"))))) + +(ert-deftest does-not-confuse-different-duplicates () + (should (equal '() (anagrams-for + "galea" + '("eagle"))))) + +(ert-deftest eliminate-anagram-subsets () + (should (equal '() (anagrams-for + "good" + '("dog" "goody"))))) + +(ert-deftest detect-anagram () + (should (equal '("inlets") (anagrams-for + "listen" + '("enlists" "google" "inlets" "banana"))))) + +(ert-deftest multiple-anagrams () + (should (equal '("gallery" "regally" "largely") + (anagrams-for + "allergy" + '("gallery" "ballerina" "regally" "clergy" "largely" "leading"))))) + +(ert-deftest case-insensitive-anagrams () + (should (equal '("Carthorse") + (anagrams-for + "Orchestra" + '("cashregister" "Carthorse" "radishes"))))) + +(ert-deftest word-is-not-own-anagram () + (should (equal '() + (anagrams-for + "banana" + '("banana"))))) + + +(provide 'anagram-test) +;;; anagram-test.el ends here diff --git a/emacs-lisp/anagram/anagram.el b/emacs-lisp/anagram/anagram.el new file mode 100644 index 0000000..0d0c333 --- /dev/null +++ b/emacs-lisp/anagram/anagram.el @@ -0,0 +1,14 @@ +;;; anagram.el --- Anagram (exercism) + +;;; Commentary: + +;;; Code: + +(require 'cl-lib) + +(defun anagrams-for(word list) + (list "tan")) + + +(provide 'anagram) +;;; anagram.el ends here |