From d655a8498c45209478a7933b05ad49f3863a345d Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Thu, 25 Nov 2021 11:14:04 -0500 Subject: acronym exercise --- exercism/emacs-lisp/acronym/.exercism/config.json | 23 ++++++++++++ .../emacs-lisp/acronym/.exercism/metadata.json | 1 + exercism/emacs-lisp/acronym/HELP.md | 41 ++++++++++++++++++++++ exercism/emacs-lisp/acronym/README.md | 28 +++++++++++++++ exercism/emacs-lisp/acronym/acronym-test.el | 28 +++++++++++++++ exercism/emacs-lisp/acronym/acronym.el | 16 +++++++++ exercism/emacs-lisp/run-exercises.el | 8 +++++ 7 files changed, 145 insertions(+) create mode 100644 exercism/emacs-lisp/acronym/.exercism/config.json create mode 100644 exercism/emacs-lisp/acronym/.exercism/metadata.json create mode 100644 exercism/emacs-lisp/acronym/HELP.md create mode 100644 exercism/emacs-lisp/acronym/README.md create mode 100644 exercism/emacs-lisp/acronym/acronym-test.el create mode 100644 exercism/emacs-lisp/acronym/acronym.el diff --git a/exercism/emacs-lisp/acronym/.exercism/config.json b/exercism/emacs-lisp/acronym/.exercism/config.json new file mode 100644 index 0000000..ef04598 --- /dev/null +++ b/exercism/emacs-lisp/acronym/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "blurb": "Convert a long phrase to its acronym", + "authors": [ + "wasamasa" + ], + "contributors": [ + "vermiculus", + "yurrriq" + ], + "files": { + "solution": [ + "acronym.el" + ], + "test": [ + "acronym-test.el" + ], + "example": [ + ".meta/example.el" + ] + }, + "source": "Julien Vanier", + "source_url": "https://github.com/monkbroc" +} diff --git a/exercism/emacs-lisp/acronym/.exercism/metadata.json b/exercism/emacs-lisp/acronym/.exercism/metadata.json new file mode 100644 index 0000000..0b68797 --- /dev/null +++ b/exercism/emacs-lisp/acronym/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"emacs-lisp","exercise":"acronym","id":"9ed15df569424784b29c7ec59bd9d43c","url":"https://exercism.org/tracks/emacs-lisp/exercises/acronym","handle":"orbekk","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/exercism/emacs-lisp/acronym/HELP.md b/exercism/emacs-lisp/acronym/HELP.md new file mode 100644 index 0000000..45e2f55 --- /dev/null +++ b/exercism/emacs-lisp/acronym/HELP.md @@ -0,0 +1,41 @@ +# Help + +## Running the tests + +Tests can be run several ways: + +1. Interactively and individually, with `M-x ert RET test-name RET` +2. Interactively and all at once, with `M-x ert RET t RET` +3. From the terminal, in batch mode, with `emacs -batch -l ert -l my-test.el -f ert-run-tests-batch-and-exit` +4. Other options can be found in the docs, `C-h i m ert RET` + +## Submitting your solution + +You can submit your solution using the `exercism submit acronym.el` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Emacs Lisp track's documentation](https://exercism.org/docs/tracks/emacs-lisp) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [The Emacs Wiki](http://emacswiki.org/) is invaluable. Spend lots of time here. +- [The Emacs Editor](http://www.gnu.org/software/emacs/manual/html_node/emacs/index.html) is the official manual for GNU Emacs. +- IRC - there are [freenode](https://freenode.net/) channels for `#emacs`, `#prelude`, and many Emacs + packages, and many helpful folks around. And with emacs, IRC is as close as + `M-x erc`. +- [Exercism Support](https://gitter.im/exercism/support) Gitter chat is also a good place to get help from the + exercism community. +- [StackOverflow](http://stackoverflow.com/questions/tagged/elisp) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. \ No newline at end of file diff --git a/exercism/emacs-lisp/acronym/README.md b/exercism/emacs-lisp/acronym/README.md new file mode 100644 index 0000000..b797b85 --- /dev/null +++ b/exercism/emacs-lisp/acronym/README.md @@ -0,0 +1,28 @@ +# Acronym + +Welcome to Acronym on Exercism's Emacs Lisp Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Convert a phrase to its acronym. + +Techies love their TLA (Three Letter Acronyms)! + +Help generate some jargon by writing a program that converts a long name +like Portable Network Graphics to its acronym (PNG). + +## Source + +### Created by + +- @wasamasa + +### Contributed to by + +- @vermiculus +- @yurrriq + +### Based on + +Julien Vanier - https://github.com/monkbroc \ No newline at end of file diff --git a/exercism/emacs-lisp/acronym/acronym-test.el b/exercism/emacs-lisp/acronym/acronym-test.el new file mode 100644 index 0000000..7ca2a96 --- /dev/null +++ b/exercism/emacs-lisp/acronym/acronym-test.el @@ -0,0 +1,28 @@ +;;; acronym-test.el --- Tests for Acronym (exercism) + +;;; Commentary: + +;;; Code + +(load-file "acronym.el") + +(ert-deftest basic () + (should (equal "PNG" (acronym "Portable Network Graphics")))) + +(ert-deftest lowercase-words () + (should (equal "ROR" (acronym "Ruby on Rails")))) + +(ert-deftest punctuation () + (should (equal "FIFO" (acronym "First In, First Out")))) + +(ert-deftest all-caps-words () + (should (equal "PHP" (acronym "PHP: Hypertext Preprocessor")))) + +(ert-deftest non-acronym-all-caps-word () + (should (equal "GIMP" (acronym "GNU Image Manipulation Program")))) + +(ert-deftest hyphenated () + (should (equal "CMOS" (acronym "Complementary metal-oxide semiconductor")))) + +(provide 'acronym-test) +;;; acronym-test.el ends here diff --git a/exercism/emacs-lisp/acronym/acronym.el b/exercism/emacs-lisp/acronym/acronym.el new file mode 100644 index 0000000..8c6a628 --- /dev/null +++ b/exercism/emacs-lisp/acronym/acronym.el @@ -0,0 +1,16 @@ +;;; acronym.el --- Acronym (exercism) + +;;; Commentary: + +;;; Code: + +(require 'cl-lib) + +(defun kj/abbrev-word (w) + (upcase (substring w 0 1))) + +(defun acronym (str) + (mapconcat 'kj/abbrev-word (split-string str "\\W+" t) "")) + +(provide 'acronym) +;;; acronym.el ends here diff --git a/exercism/emacs-lisp/run-exercises.el b/exercism/emacs-lisp/run-exercises.el index 5095afa..e558d62 100644 --- a/exercism/emacs-lisp/run-exercises.el +++ b/exercism/emacs-lisp/run-exercises.el @@ -66,4 +66,12 @@ (response-for "WHAT!") (response-for "Okay")) +(load-file "word-count/word-count.el") +(kj-display "Word count" + (word-count "They're a large crowd with a crowd with they.")) + +(load-file "acronym/acronym.el") +(kj-display "Acronyms" + (acronym "GNU Image Manipulation program")) + (provide 'hello) -- cgit v1.2.3