Fill large area with random blocks

What is the best way to fill a large area with random blocks (like for every block it's randomly evaluated which block is placed there)? I tried to loop through every block in that area but that easily exceeds the max_command_chain_length I also thought of using the place command with it's integrity value to generate random blocks to then replace them with the real blocks but this also doesn't seem to be a good option since you can't make a structure of a variable size right? For context, this is what I want to achieve (see image): - fill an area with random blocks (the block types are stored in a storage together with their chances to get selected) - make the size of that area be variable (which is also stored in a storage)
Continue to help post