(ns zipzag
(:require [clojure.string :as str]))
(defn print-zigzag [s]
(let [a (-> (str/replace s #"\s+" "") (str " "))
re #(-> (str/replace a % %2) str/trimr)]
(println (re #"(.)." "$1 "))
(println (re #".(.)" " $1"))))
(print-zigzag "123456789")
(print-zigzag "The earth turns around the sun.")
KG5zIHppcHphZwoJKDpyZXF1aXJlIFtjbG9qdXJlLnN0cmluZyA6YXMgc3RyXSkpCgooZGVmbiBwcmludC16aWd6YWcgW3NdCiAgKGxldCBbYSAoLT4gKHN0ci9yZXBsYWNlIHMgIyJccysiICIiKSAoc3RyICIgIikpCiAgICAgICAgcmUgIygtPiAoc3RyL3JlcGxhY2UgYSAlICUyKSBzdHIvdHJpbXIpXQogICAgKHByaW50bG4gKHJlICMiKC4pLiIgIiQxICIpKQogICAgKHByaW50bG4gKHJlICMiLiguKSIgIiAkMSIpKSkpCgoocHJpbnQtemlnemFnICIxMjM0NTY3ODkiKQoocHJpbnQtemlnemFnICJUaGUgZWFydGggdHVybnMgYXJvdW5kIHRoZSBzdW4uIikK