From 321825828ac918bad28d0597a8616c6dc9802c3c Mon Sep 17 00:00:00 2001 From: Andinus Date: Wed, 11 Aug 2021 15:26:15 +0530 Subject: Add solved exercises --- emacs-lisp/anagram/README.md | 13 +++++++++ emacs-lisp/anagram/anagram-test.el | 54 ++++++++++++++++++++++++++++++++++++++ emacs-lisp/anagram/anagram.el | 14 ++++++++++ 3 files changed, 81 insertions(+) create mode 100644 emacs-lisp/anagram/README.md create mode 100644 emacs-lisp/anagram/anagram-test.el create mode 100644 emacs-lisp/anagram/anagram.el (limited to 'emacs-lisp/anagram') 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 -- cgit 1.4.1-2-gfad0