( use 'clojure.string)
(defn f [n]
(let [s (str n)
i (map (fn [x] (- (int x) 48)) (str(Math/abs n)))]
(+
(reduce + (cons (* (first i) (if (< n 0) -1 1)) (rest i)))
n
(count s))))
(defn g [n]
(let [s (str (Math/abs n))
c (count (str n))
digits-str (str (if (< n 0) "-" "") (join "+" s))
ints (map (fn [x] (- (int x) 48)) s)
digits (cons (* (first ints) (if (< n 0) -1 1)) (rest ints))
sum (reduce + digits)]
(str n "+" c "+(" digits-str ")=" (+ sum c n))))
(println (f 99))
(println (f -123))
(println (f 0))
(println (f 1))
(println (g 99))
(println (g -123))
(println (g 0))
(println (g 1))
KHVzZSAnY2xvanVyZS5zdHJpbmcpCihkZWZuIGYgW25dCiAgKGxldCBbcyAoc3RyIG4pCiAgICAgICAgaSAobWFwIChmbiBbeF0gKC0gKGludCB4KSA0OCkpIChzdHIoTWF0aC9hYnMgbikpKV0KICAgICgrCiAgICAgIChyZWR1Y2UgKyAoY29ucyAoKiAoZmlyc3QgaSkgKGlmICg8IG4gMCkgLTEgMSkpIChyZXN0IGkpKSkKICAgICAgbgogICAgICAoY291bnQgcykpKSkKKGRlZm4gZyBbbl0KICAobGV0IFtzIChzdHIgKE1hdGgvYWJzIG4pKQogICAgICAgIGMgKGNvdW50IChzdHIgbikpCiAgICAgICAgZGlnaXRzLXN0ciAoc3RyIChpZiAoPCBuIDApICItIiAiIikgKGpvaW4gIisiIHMpKQogICAgICAgIGludHMgKG1hcCAoZm4gW3hdICgtIChpbnQgeCkgNDgpKSBzKQogICAgICAgIGRpZ2l0cyAoY29ucyAoKiAoZmlyc3QgaW50cykgKGlmICg8IG4gMCkgLTEgMSkpIChyZXN0IGludHMpKQogICAgICAgIHN1bSAocmVkdWNlICsgZGlnaXRzKV0KICAgIChzdHIgbiAiKyIgYyAiKygiIGRpZ2l0cy1zdHIgIik9IiAoKyBzdW0gYyBuKSkpKQoKKHByaW50bG4gKGYgOTkpKQoocHJpbnRsbiAoZiAtMTIzKSkKKHByaW50bG4gKGYgMCkpCihwcmludGxuIChmIDEpKQoocHJpbnRsbiAoZyA5OSkpCihwcmludGxuIChnIC0xMjMpKQoocHJpbnRsbiAoZyAwKSkKKHByaW50bG4gKGcgMSkp