Clojure:
(defn row [max i] (apply str (concat (repeat (- max i) \space) (repeat (inc (* 2 i)) \*)))) (defn diamond [max] (let [is (range 0 max)] (->> (concat is (rest (reverse is))) (map (partial row max)) (clojure.string/join \newline))))
as pseudocode:
row = fn(max, i) => pad = " " * (max - i) stars = "*" * (2 * i + 1) stars + pad diamond = fn(max) => top_nums = up_to(0, max) btm_nums = drop_first(reverse(top_nums)) rows = row(max, i) for each i in (top_nums + btm_nums) join(rows, "\n")
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Clojure:
as pseudocode: