     (map flatten)
     (mapv vec)))
 
+(defn blocks*
+  "Create a layout for n icons, in cols columns, organised into blocks of w width and h height. Blocks are separated
+  by rows or columns of zeroes. Full cells are indicated by non-sero entries (mostly 1s)."
+  [n cols w h]
+  (let [blocks-per-row (Math.ceil (/ cols w))
+        block-size (* w h)
+        full-block-count (quot n block-size)
+        remainder (rem n block-size)
+        row-blocks-capacity (* cols h)
+        rows-of-full-blocks (quot n row-blocks-capacity)
+        partial-row-full-blocks (rem n row-blocks-capacity)
+        full-blocks-in-partial-row (quot partial-row-full-blocks block-size)
+        empty-row (->> (repeat cols 0)
+                       (partition w)
+                       (interpose 0)
+                       (flatten))
+        full-row-of-blocks (->> (repeat cols 1)
+                                (partition w)
+                                (interpose 0)
+                                (flatten)
+                                (repeat h)
+                                (repeat rows-of-full-blocks)
+                                (interpose empty-row))
+        last-block-count (- n (* rows-of-full-blocks row-blocks-capacity) (* full-blocks-in-partial-row block-size))]
+    [rows-of-full-blocks
+     full-row-of-blocks
+     "Unfinished"]
+
+    )
+  )
+
 (comment
   (blocks 500 20 5 5)
+  (blocks* 500 20 5 5)
   )
 
-#_(defn row-n-m
-    "Layout for row of length m with n icons showing"
-    [n m]
-    (let [row []]
-      (for [col (range m)]
-        (loop [row []
-               i 0]
-          (if (< i m)
-            (recur (conj row (if (and (pos? i) (mod i 6)) 1 0)) (inc i))
-            row)))))
-
 (comment
+  (blocks 33 10 5 2)
+  (blocks* 33 10 5 2)
+
   (row-n-m 3 5)
   ; => [1 1 1 0 0]
   (block-n-k 3 5)

    (map flatten)
    (mapv vec)))

(defn block-k-n
  [n k]
  (->>                                                      ;(row-n-m* n 20 20)
    (range (* k (Math.ceil (/ n k))))
    (map-indexed #(if (< %1 n) 1 0))
    (partition-all k)
    (partition-all 5)
    (interpose (repeat k 0))
    (flatten)
    (partition-all k)
    (map (partial partition-all 2))
    (map (partial interpose [0]))
    (map flatten)
    (mapv vec)))

(defn blocks
  [n cols w h]
  (->>                                                      ;(row-n-m* n 20 20)
    (range (* cols (Math.ceil (/ n cols))))
    (map-indexed #(if (< %1 n) 1 0))
    (partition-all cols)


(defn dicen
  "layout n icons in an easy to count manner (dice-like for small n)"
  [n highlight]
  (cond
    (< n 10) (get dice n)
    (<= n 20) (blocks n 5 5 2)
