To better understand my issue, I created a StackBlitz demo: https://stackblitz.com/edit/angular-aqmahw?file=src/app/tiles-example.css
My tiles can have four different widths (25%, 50%, 75%, 100%).
The tiles must fit on only two lines, so if all the tiles are 25% wide, there can be up to 8 of them.
I'm currently looking for an algorithm that can identify the empty spaces on these two lines and determine their sizes. This way, when adding a tile, I want it to fill in these empty spaces rather than just appending it to the end of the list.
Could anyone assist me with developing this algorithm?