Repository: exercism/clojure
Pull request #186 (2017-09-20 04:30:10)

adding series
another Unimplemented exercise.


Patch:
diff --git a/config.json b/config.json
index 7828393..625c926 100644
--- a/config.json
+++ b/config.json
@@ -75,6 +75,16 @@
 
       ]
     },
+    {
+      "uuid": "c34af548-c5f6-43a9-84e2-c4166605fc8e",
+      "slug": "series",
+      "core": false,
+      "unlocked_by": null,
+      "difficulty": 1,
+      "topics": [
+
+      ]
+    },
     {
       "uuid": "66d97ae9-36ac-47c6-8b9f-e77ce498fc70",
       "slug": "nucleotide-count",
diff --git a/exercises/series/README.md b/exercises/series/README.md
new file mode 100644
index 0000000..5005749
--- /dev/null
+++ b/exercises/series/README.md
@@ -0,0 +1,28 @@
+# Series
+
+Given a string of digits, output all the contiguous substrings of length `n` in
+that string.
+
+For example, the string "49142" has the following 3-digit series:
+
+- 491
+- 914
+- 142
+
+And the following 4-digit series:
+
+- 4914
+- 9142
+
+And if you ask for a 6-digit series from a 5-digit string, you deserve
+whatever you get.
+
+Note that these series are only required to occupy *adjacent positions*
+in the input; the digits need not be *numerically consecutive*.
+
+## Source
+
+See more at [http://projecteuler.net/problem=8](http://projecteuler.net/problem=8)
+
+## Submitting Incomplete Solutions
+It's possible to submit an incomplete solution so you can see how others have completed the exercise.
diff --git a/exercises/series/project.clj b/exercises/series/project.clj
new file mode 100644
index 0000000..1ec2224
--- /dev/null
+++ b/exercises/series/project.clj
@@ -0,0 +1,4 @@
+(defproject series "0.1.0-SNAPSHOT"
+  :description "series exercise"
+  :url "https://github.com/exercism/xclojure/tree/master/exercises/series"
+  :dependencies [[org.clojure/clojure "1.8.0"]])
diff --git a/exercises/series/src/example.clj b/exercises/series/src/example.clj
new file mode 100644
index 0000000..89bdce4
--- /dev/null
+++ b/exercises/series/src/example.clj
@@ -0,0 +1,9 @@
+(ns series)
+
+(defn slices [string n]
+  (if (zero? n)
+    [""]
+    (loop [string string, acc []]
+      (if (< (count string) n)
+        acc
+        (recur (rest string) (conj acc (apply str (take n string))))))))
diff --git a/exercises/series/src/series.clj b/exercises/series/src/series.clj
new file mode 100644
index 0000000..97d2473
--- /dev/null
+++ b/exercises/series/src/series.clj
@@ -0,0 +1,3 @@
+(ns series)
+
+(defn slices [string n])


Test patch:
diff --git a/exercises/series/test/series_test.clj b/exercises/series/test/series_test.clj
new file mode 100644
index 0000000..b4728dc
--- /dev/null
+++ b/exercises/series/test/series_test.clj
@@ -0,0 +1,23 @@
+(ns series-test
+  (require [clojure.test :refer [deftest is testing]]
+           [series  :refer [slices]]))
+
+(deftest empty-string
+  (testing "empty string with any number"
+    (is (= [] (slices "" 1)))))
+
+(deftest number-eq-zero
+  (testing "number = 0"
+    (is (= [""] (slices "123" 0)))))
+
+(deftest number>string
+  (testing "number > string-length"
+    (is (= [] (slices "123" 1000)))))
+
+(deftest number=string
+  (testing "number = string-length"
+    (is (= ["123"] (slices "123" 3)))))
+
+(deftest number<string
+  (testing "number < string-length"
+    (is (= #{"123" "234" "345"} (set (slices "12345" 3))))))