# [Charcoal], <s>27</s> <s>23</s> 18 bytes ≔EX²N↨⁴↨ι²υIE⊗υ⁺ιυ [Try it online!][TIO-kqry9i0f] Link is to verbose version of code. Explanation: Now a port of @tsh's Python answer. ≔EX²N↨⁴↨ι²υ Map the numbers up to 2ⁿ by converting them to base 2 and then interpreting the result as base 4. IE⊗υ⁺ιυ Vectorised add the doubled array to itself as a matrix. Previous <s>27</s> 23 byte answer uses a different approach that is interesting in its own right because some golfing languages have built-ins for things like group index by value or sort array by key. ≔EX⁴N↨²÷↨ι⁴¦²υIE⊕⌈υ⌕Aυι [Try it online!][TIO-kqrccaew] Link is to verbose version of code. Explanation: ≔EX⁴N↨²÷↨ι⁴¦²υ For each element in the final diagram, convert it to base 4, halve the digits, then convert from base 2. This gives the row number for that element. IE⊕⌈υ⌕Aυι For each row list the elements assigned to that row. [Charcoal]: https://github.com/somebody1234/Charcoal [TIO-kqry9i0f]: https://tio.run/##S85ILErOT8z5/9@xuDgzPU/DN7FAIyC/PLVIw0hHwTOvoLTErzQ3CcjV1NRRcEosTtUwgdKZOgpGmiDRUk1rroCizLwSDefE4hKwCS75pUk5qSkapUDpgJzSYpDiUqBiTev//03@65blAAA "Charcoal – Try It Online" [TIO-kqrccaew]: https://tio.run/##HYw7DsIwEER7TuFyLZkmcpcqgJBSgHIFY69gJXsT@RO4vbFTzps3Yz8m2tX4WqeU6M3wMBss6xcjaCVm3kp@lvBqUUolLiYhDJ3nG@3kEA5CSujWDrI7RY6nJRJnuJqUj7@ZbcSAnNG1/KNQApTu3ond5D0UJaiN5Virrufd/wE "Charcoal – Try It Online"