i want to split 100% in a given number of columns. but the width of the columns should be random. here is my first try. but it's static to 5 columns. any ideas to make it dynamic?
(defn create-columns []
(let [col1 (int (random/number 14 26))
col2 (int (random/number 14 26))
col3 (int (random/number 14 26))
col4 (int (random/number 14 26))
col5 (- 100 (+ col1 col2 col3 col4))]
[{:width col1, :left 0}
{:width col2, :left (int col1)}
{:width col3, :left (+ col1 col2)}
{:width col4, :left (+ col1 col2 col3)}
{:width col5, :left (+ col1 col2 col3 col4)}]))
result should be like
[{:width 23, :left 0} {:width 24, :left 23} {:width 23, :left 47} {:width 14, :left 70} {:width 16, :left 84}]
and ideas?
question from:https://stackoverflow.com/questions/65892066/split-100-in-a-given-number-of-columns-width-random-width