I think it would be easier to start with real values to get a correct answer.
I just did some tests and it's not necessarily too complicated, the problem is just to have reference values to be sure.
If I understood correctly, you want to know the intervals between your boxes, knowing that these values are integer, between a maximum and a mini, and that you can have a maximum of two different intervals.
The problem is that you can have several solutions.
Starting from the fact that we only know the total length, the length of a box and the minimum/maximum values of the spacings, here is what it would look like:
In fact, the best would be to have a list of proposals that the user could choose afterwards (could choose = in my excel sheet that will generate my assembly).
Like what:
For a total length of 1000mm
With 6 x 80mm boxes
6*80 = 480
1000-480 = 520 spacing
There are 5 spacing (6 boxes -1).
Minimum Spacing: 100
Maximum spacing: 150
Equal spacing on both sides = 104mm
--
Serves 4 and 1
For 3 and 2
For 2 and 3 (inverse so the same)
For 1 and 4 (inverse so the same)
---
For 4 and 1 =
Spacing 1: /
Spacing 2: /
For 3 and 2 =
Spacing 1: /
Spacing 2: /
---
Notice that there is a list of possibilities such as for example for 12 spacings:
The solution proposed by Franck51 seems to work, for my part I prefer to use the excel solver. The problem is that with an identical number of boxes and spaces we find different space values
Franck51
7 boxes width 80
2 spaces width 115
4 spaces width 116
Me
7 boxes width 80
2 spaces width 131
4 spaces width 108
I use the following solver constraints: (I don't know if they are saved with the excel sheet)
The difference actually comes simply from the calculation system.
In fact, to find out the spaces, I divide my total space by a value (= number of boxes - 1) and I use this value as a reference to find the second one.
This allows you to have similar values as you have seen.
Solution N°1
7 boxes width 80
2 spaces width 115
4 spaces width 116
Or
Solution N°2
7 boxes width 80
4 spaces width 115
4 spaces width 117
Or
Solution N°3
7 boxes width 80
5 spaces width 115
1 spaces width 119
Or your solution
Depending on the desired result, there are certainly as many calculation systems.