summary refs log tree commit diff stats
path: root/emacs-lisp/two-fer
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-08-11 15:26:15 +0530
committerAndinus <andinus@nand.sh>2021-08-11 15:26:15 +0530
commit321825828ac918bad28d0597a8616c6dc9802c3c (patch)
tree0b8e9cb1012197750eb58e972736319b2a6abac2 /emacs-lisp/two-fer
parent2979ef790ac5b8f58495e0dd08cafd6a3a2e30a5 (diff)
downloadexercism-321825828ac918bad28d0597a8616c6dc9802c3c.tar.gz
Add solved exercises
Diffstat (limited to 'emacs-lisp/two-fer')
-rw-r--r--emacs-lisp/two-fer/README.md19
-rw-r--r--emacs-lisp/two-fer/two-fer-test.el21
-rw-r--r--emacs-lisp/two-fer/two-fer.el11
3 files changed, 51 insertions, 0 deletions
diff --git a/emacs-lisp/two-fer/README.md b/emacs-lisp/two-fer/README.md
new file mode 100644
index 0000000..f60404a
--- /dev/null
+++ b/emacs-lisp/two-fer/README.md
@@ -0,0 +1,19 @@
+# Two Fer
+
+`Two-fer` or `2-fer` is short for two for one. One for you and one for me.
+
+```text
+"One for X, one for me."
+```
+
+When X is a name or "you".
+
+If the given name is "Alice", the result should be "One for Alice, one for me."
+If no name is given, the result should be "One for you, one for me."
+
+## Source
+
+[https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer)
+
+## 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/two-fer/two-fer-test.el b/emacs-lisp/two-fer/two-fer-test.el
new file mode 100644
index 0000000..f21c756
--- /dev/null
+++ b/emacs-lisp/two-fer/two-fer-test.el
@@ -0,0 +1,21 @@
+;;; two-fer-test.el --- Tests for Two-fer (exercism)
+
+;;; Commentary:
+;; Common test data version: 1.2.0 4fc1acb
+
+;;; Code:
+
+(load-file "two-fer.el")
+
+(ert-deftest no-name-given ()
+  (should (string= (two-fer) "One for you, one for me.")))
+
+(ert-deftest a-name-given ()
+  (should (string= (two-fer "Alice") "One for Alice, one for me.")))
+
+(ert-deftest another-name-given ()
+  (should (string= (two-fer "Bob") "One for Bob, one for me.")))
+
+(provide 'two-fer-test)
+
+;;; two-fer-test.el ends here
diff --git a/emacs-lisp/two-fer/two-fer.el b/emacs-lisp/two-fer/two-fer.el
new file mode 100644
index 0000000..3c3620d
--- /dev/null
+++ b/emacs-lisp/two-fer/two-fer.el
@@ -0,0 +1,11 @@
+;;; two-fer.el --- Two-fer Exercise (exercism)
+
+;;; Commentary:
+
+;;; Code:
+
+(defun two-fer(&optional name)
+  (format "One for %s, one for me." (or name "you")))
+
+(provide 'two-fer)
+;;; two-fer.el ends here