Let's say we want to find every possible way of placing 3 blocks each of length 2 into a line which is 8 units long. There are 10 possible solutions:
How can we find these? I first encountered this problem during my honours project and the solution involves a nice little recursive function, so I thought I might as well share. We always begin by building the equivalent of the topmost solution above: all blocks adjacent to each other and as far left as possible. From here we take the rightmost block and shift it rightwards one cell at a time, storing the result, until we hit the end of the line. Then we grab the preceding block and shift that by one cell, then continue shifting the last block again. This will find all the configurations in the order given above, top to bottom. Below is a simple implementation in Lua where we're treating the line as a string for which each block has it's own letter and empty cells are '-'. The recursion happens in the find_spreads function.
Notice that this can also handle having a minimum number of spaces between each pair of blocks. I've made a little PICO-8 program to demonstrate the algorithm. Below left you can see the rendering of our example setup: block lengths of 2, 2, 2; line length of 8 and no minimum number of spaces. On the right is every configuration for block lengths 1, 2, 3; line length 11 and at least 1 space between each pair. If you didn't care about preserving block order and simply wanted every configuration of a set of blocks, you could run the above algorithm multiple times with every possible rearrangement of the initial block order.