You are viewing a single comment's thread. Return to all comments →
My solution in Clojure!
(defn transform-into-groups [mystr] (-> (clojure.string/replace mystr #"([a-z])(?!\1)" "$1 ") (clojure.string/split #" "))) (defn encode-groups [groups] (->> (map (fn [group] (str (subs group 0 1) (cond (>= 1 (count group)) "" :else (count group)))) groups) (clojure.string/join ""))) (doseq [ln (line-seq (java.io.BufferedReader. *in*))] (-> (transform-into-groups ln) encode-groups println))
Seems like cookies are disabled on this browser, please enable them to open this website
String Compression
You are viewing a single comment's thread. Return to all comments →
My solution in Clojure!