summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2021-11-26 07:29:24 -0500
committerKjetil Orbekk <kj@orbekk.com>2021-11-26 07:29:24 -0500
commit65951ec5972aec2abbfc8d0dfa2a7227a0fa7223 (patch)
treed655f7f620d7aad398c8a5399001bffcd79b1696
parent26f140d4fd3eabe3a922deef8926869da352b1b5 (diff)
add another exercise
-rw-r--r--exercism/emacs-lisp/armstrong-numbers/.exercism/config.json23
-rw-r--r--exercism/emacs-lisp/armstrong-numbers/.exercism/metadata.json1
-rw-r--r--exercism/emacs-lisp/armstrong-numbers/HELP.md41
-rw-r--r--exercism/emacs-lisp/armstrong-numbers/README.md32
-rw-r--r--exercism/emacs-lisp/armstrong-numbers/armstrong-numbers-test.el41
-rw-r--r--exercism/emacs-lisp/armstrong-numbers/armstrong-numbers.el8
6 files changed, 146 insertions, 0 deletions
diff --git a/exercism/emacs-lisp/armstrong-numbers/.exercism/config.json b/exercism/emacs-lisp/armstrong-numbers/.exercism/config.json
new file mode 100644
index 0000000..947afa0
--- /dev/null
+++ b/exercism/emacs-lisp/armstrong-numbers/.exercism/config.json
@@ -0,0 +1,23 @@
+{
+ "blurb": "Determine if a number is an Armstrong number",
+ "authors": [
+ "cpaulbond"
+ ],
+ "contributors": [
+ "benreyn",
+ "vermiculus"
+ ],
+ "files": {
+ "solution": [
+ "armstrong-numbers.el"
+ ],
+ "test": [
+ "armstrong-numbers-test.el"
+ ],
+ "example": [
+ ".meta/example.el"
+ ]
+ },
+ "source": "Wikipedia",
+ "source_url": "https://en.wikipedia.org/wiki/Narcissistic_number"
+}
diff --git a/exercism/emacs-lisp/armstrong-numbers/.exercism/metadata.json b/exercism/emacs-lisp/armstrong-numbers/.exercism/metadata.json
new file mode 100644
index 0000000..648fefd
--- /dev/null
+++ b/exercism/emacs-lisp/armstrong-numbers/.exercism/metadata.json
@@ -0,0 +1 @@
+{"track":"emacs-lisp","exercise":"armstrong-numbers","id":"4af97d50f36f46e3bf7bd0759b3de2f4","url":"https://exercism.org/tracks/emacs-lisp/exercises/armstrong-numbers","handle":"orbekk","is_requester":true,"auto_approve":false} \ No newline at end of file
diff --git a/exercism/emacs-lisp/armstrong-numbers/HELP.md b/exercism/emacs-lisp/armstrong-numbers/HELP.md
new file mode 100644
index 0000000..27246d0
--- /dev/null
+++ b/exercism/emacs-lisp/armstrong-numbers/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 armstrong-numbers.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/armstrong-numbers/README.md b/exercism/emacs-lisp/armstrong-numbers/README.md
new file mode 100644
index 0000000..6ce997b
--- /dev/null
+++ b/exercism/emacs-lisp/armstrong-numbers/README.md
@@ -0,0 +1,32 @@
+# Armstrong Numbers
+
+Welcome to Armstrong Numbers on Exercism's Emacs Lisp Track.
+If you need help running the tests or submitting your code, check out `HELP.md`.
+
+## Instructions
+
+An [Armstrong number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that is the sum of its own digits each raised to the power of the number of digits.
+
+For example:
+
+- 9 is an Armstrong number, because `9 = 9^1 = 9`
+- 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 1`
+- 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153`
+- 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190`
+
+Write some code to determine whether a number is an Armstrong number.
+
+## Source
+
+### Created by
+
+- @cpaulbond
+
+### Contributed to by
+
+- @benreyn
+- @vermiculus
+
+### Based on
+
+Wikipedia - https://en.wikipedia.org/wiki/Narcissistic_number \ No newline at end of file
diff --git a/exercism/emacs-lisp/armstrong-numbers/armstrong-numbers-test.el b/exercism/emacs-lisp/armstrong-numbers/armstrong-numbers-test.el
new file mode 100644
index 0000000..4851dbf
--- /dev/null
+++ b/exercism/emacs-lisp/armstrong-numbers/armstrong-numbers-test.el
@@ -0,0 +1,41 @@
+;;; armstrong-numbers-test.el --- Tests for armstrong-numbers (exercism)
+
+;;; Commentary:
+
+;;; Code:
+
+(load-file "armstrong-numbers.el")
+
+(ert-deftest armstrong-number-5 ()
+ "Single digit numbers are Armstrong numbers"
+ (should (armstrong-p 5)))
+
+(ert-deftest not-armstrong-number-10 ()
+ "There are no 2 digit Armstrong numbers"
+ (should (not (armstrong-p 10))))
+
+(ert-deftest armstrong-number-153 ()
+ "Three digit number that should an Armstrong number"
+ (should (armstrong-p 153)))
+
+(ert-deftest not-armstrong-number-100 ()
+ "Three digit number that should an Armstrong number"
+ (should (not (armstrong-p 100))))
+
+(ert-deftest armstrong-number-9474 ()
+ "Four digit number that should an Armstrong number"
+ (should (armstrong-p 9474)))
+
+(ert-deftest not-armstrong-number-9475 ()
+ "Four digit number that should not an Armstrong number"
+ (should (not (armstrong-p 9476))))
+
+(ert-deftest armstrong-number-9926315 ()
+ "Seven digit number that should an Armstrong number"
+ (should (armstrong-p 9926315)))
+
+(ert-deftest not-armstrong-number-9926314 ()
+ "Seven digit number that should not an Armstrong number"
+ (should (not (armstrong-p 9926314))))
+
+;;; armstrong-numbers-test.el ends here
diff --git a/exercism/emacs-lisp/armstrong-numbers/armstrong-numbers.el b/exercism/emacs-lisp/armstrong-numbers/armstrong-numbers.el
new file mode 100644
index 0000000..d41293c
--- /dev/null
+++ b/exercism/emacs-lisp/armstrong-numbers/armstrong-numbers.el
@@ -0,0 +1,8 @@
+;;; armstrong-numbers.el --- armstrong-numbers Exercise (exercism)
+
+;;; Commentary:
+
+;;; Code:
+
+(provide 'armstrong-numbers)
+;;; armstrong-numbers.el ends here