summary refs log tree commit diff stats
path: root/clojure/two-fer
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-09-05 16:36:40 +0530
committerAndinus <andinus@nand.sh>2021-09-05 16:36:40 +0530
commit38b4e6fa229e65eae10f8a06c81ef1a0802d45f5 (patch)
treecb94ab163b2f7607f38d01753d286189ddcda259 /clojure/two-fer
parente4fd875702b7be18cfc3eccdb10fb21a065ae5e1 (diff)
downloadexercism-38b4e6fa229e65eae10f8a06c81ef1a0802d45f5.tar.gz
Clojure: Add Hello World solution and Two Fer exercise
Diffstat (limited to 'clojure/two-fer')
-rw-r--r--clojure/two-fer/HELP.md57
-rw-r--r--clojure/two-fer/README.md47
-rw-r--r--clojure/two-fer/project.clj4
-rw-r--r--clojure/two-fer/src/two_fer.clj5
-rw-r--r--clojure/two-fer/test/two_fer_test.clj12
5 files changed, 125 insertions, 0 deletions
diff --git a/clojure/two-fer/HELP.md b/clojure/two-fer/HELP.md
new file mode 100644
index 0000000..02919a0
--- /dev/null
+++ b/clojure/two-fer/HELP.md
@@ -0,0 +1,57 @@
+# Help
+
+## Running the tests
+
+Leiningen can be used to run the exercise's test by running the following command from the exercise's directory:
+
+```bash
+lein test
+```
+
+## REPL
+
+To use the REPL to run the exercise's test, run the following command from the exercise's directory:
+
+```bash
+$ lein repl
+```
+
+Then `require` the exercise's test namespace and the Clojure test namespace):
+
+```clojure
+;; replace <exercise> with the exercise's name
+=> (require '<exercise>-test)
+```
+
+Then call `run-tests` on `<exercise>-test`:
+
+```clojure
+;; replace <exercise> with the exercise's name
+=> (clojure.test/run-tests '<exercise>-test)
+```
+
+## Submitting your solution
+
+You can submit your solution using the `exercism submit src/two_fer.clj` 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 [Clojure track's documentation](https://exercism.org/docs/tracks/clojure)
+- [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:
+
+- [ClojureDocs](https://clojuredocs.org) A repository of language references and examples by function or keyword.
+- [/r/clojure](https://www.reddit.com/r/clojure) is the C# subreddit.
+- [StackOverflow](http://stackoverflow.com/questions/tagged/clojure) 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/clojure/two-fer/README.md b/clojure/two-fer/README.md
new file mode 100644
index 0000000..150ad00
--- /dev/null
+++ b/clojure/two-fer/README.md
@@ -0,0 +1,47 @@
+# Two Fer
+
+Welcome to Two Fer on Exercism's Clojure Track.
+If you need help running the tests or submitting your code, check out `HELP.md`.
+
+## Instructions
+
+`Two-fer` or `2-fer` is short for "two for one": One for you and one for me.
+
+Given a name, return a string with the message:
+
+```text
+One for name, one for me.
+```
+
+Where "name" is the given name.
+
+However, if the name is missing, return the string:
+
+```text
+One for you, one for me.
+```
+
+Here are some examples:
+
+|Name    |String to return
+|:-------|:------------------
+|Alice   |One for Alice, one for me.
+|Bob     |One for Bob, one for me.
+|        |One for you, one for me.
+|Zaphod  |One for Zaphod, one for me.
+
+## Source
+
+### Created by
+
+- @sjwarner-bp
+
+### Contributed to by
+
+- @AndreaCrotti
+- @haus
+- @sjwarner
+
+### Based on
+
+https://github.com/exercism/problem-specifications/issues/757
\ No newline at end of file
diff --git a/clojure/two-fer/project.clj b/clojure/two-fer/project.clj
new file mode 100644
index 0000000..6c67fbd
--- /dev/null
+++ b/clojure/two-fer/project.clj
@@ -0,0 +1,4 @@
+(defproject two-fer "0.1.0-SNAPSHOT"
+  :description "two-fer exercise."
+  :url "https://github.com/exercism/clojure/tree/master/exercises/two-fer"
+  :dependencies [[org.clojure/clojure "1.10.0"]])
diff --git a/clojure/two-fer/src/two_fer.clj b/clojure/two-fer/src/two_fer.clj
new file mode 100644
index 0000000..ab89be3
--- /dev/null
+++ b/clojure/two-fer/src/two_fer.clj
@@ -0,0 +1,5 @@
+(ns two-fer)
+
+(defn two-fer [name] ;; <- arglist goes here
+  ;; your code goes here
+)
diff --git a/clojure/two-fer/test/two_fer_test.clj b/clojure/two-fer/test/two_fer_test.clj
new file mode 100644
index 0000000..a1ac329
--- /dev/null
+++ b/clojure/two-fer/test/two_fer_test.clj
@@ -0,0 +1,12 @@
+(ns two-fer-test
+  (:require [clojure.test :refer [deftest is]]
+            two-fer))
+
+(deftest two-fer-test
+  (is (= "One for you, one for me." (two-fer/two-fer))))
+
+(deftest name-alice-test
+  (is (= "One for Alice, one for me." (two-fer/two-fer "Alice"))))
+
+(deftest name-bob-test
+  (is (= "One for Bob, one for me." (two-fer/two-fer "Bob"))))