 
 (defn run-length-decode
   "decodes a run-length-encoded string"
-  [cipher-text])
+  [cipher-text]
+  (loop [acc "" char-seq cipher-text stack []]
+    (let [current-char (first char-seq)]
+      (cond
+        (empty? char-seq) acc
+        (java.lang.Character/isDigit current-char) (recur acc (rest char-seq) (vector (if (empty? stack) (java.lang.Character/digit current-char 10) (+ (java.lang.Character/digit current-char 10) (* 10 (last stack))))))
+        :else (recur (str acc (if (empty? stack) (str current-char) (string/join (repeat (last stack) (str current-char))))) (rest char-seq) [])))))

  (:require [clojure.string :as string :only join]))

;; Pensez à faire une version avec reduce
;; Changer les noms des variables c ==> current-char
;; Variabiliser (peek (peek acc)) dans un let
(defn plain-text-to-vector
  "transform the plain text in a vector of vector of characters"
  [plain-text]
  (loop [acc [] char-seq plain-text]
    (let [current-char (first char-seq) current-vector (peek acc)]

            (= current-char (peek current-vector)) (recur (conj (vec (butlast acc)) (conj current-vector current-char)) (rest char-seq)))))))

(defn vector-to-cipher-text
  "transforms a vector of vector of characters in the run-length encoded string"
  [char-seq]
  (->> char-seq
       (map #(vector (let [number-of-chars (count %)]
