fork download
  1. (ns zipzag
  2. (:require [clojure.string :as str]))
  3.  
  4. (defn print-zigzag [s]
  5. (let [a (-> (str/replace s #"\s+" "") (str " "))
  6. re #(-> (str/replace a % %2) str/trimr)]
  7. (println (re #"(.)." "$1 "))
  8. (println (re #".(.)" " $1"))))
  9.  
  10. (print-zigzag "123456789")
  11. (print-zigzag "The earth turns around the sun.")
  12.  
Success #stdin #stdout 1.36s 389120KB
stdin
Standard input is empty
stdout
1 3 5 7 9
 2 4 6 8
T e a t t r s r u d h s n
 h e r h u n a o n t e u .