You are viewing a single comment's thread. Return to all comments →
Don't create too many intermedite string objects. That is the key. The below solution passes all test cases.
(require '[clojure.string :as str]) (defn indices [] (reductions + 1 (cycle [-1 3]))) (defn permute [s] (let [n (count s)] (str/join (map #(nth s %) (take n (indices)))))) (let [input (slurp *in*) [q & strings] (str/split-lines input)] (doseq [s strings] (println (permute s))))
Seems like cookies are disabled on this browser, please enable them to open this website
String-o-Permute
You are viewing a single comment's thread. Return to all comments →
Don't create too many intermedite string objects. That is the key. The below solution passes all test cases.