Script to fill void with different sized squares

I am trying to figure out a way, to fill out an area with different sizes of predefined squares. The idea would be, that the area to be filled out, has a threshold of let say 5% that the area can shrink, or expand for the predefined squares to fill out the area. There could also be a % that the area doesn’t need to have filled out… But most importantly is, that the script uses the predefined squares to fill out the area, and that it gives different examples of how this arrangement of the predefined squares could look.

Hope someone can help!

Similar things have been done before. I remember @laurent_delrieu doing some. Perhaps check the links in the quoted post below and see if anything is useful?

Thanks @martynjhogg, @ronja.elisabeth Look also to that
Nesting randomly (sort of Wordle)