# How to find the size of gaps between entries in an array so that the first and last element of the array is filled and the gaps are all of equal size? I have an array a of n entries. I need to place a token on the first and last position of that array, so `a = 1` and `a[n-1] = 1`.

I now want to place additional tokens into that array with a distance inbetween each index i where `a[i] = 1` that is greater than 2 (so placing a token on every index is invalid as well as alternating using and not using an entry is invalid). Phrazed differently: I want that `sum(a) < n/2` . The gap inbetween each token should be the same, so say with an array of size 16,

`a = 1, a = 1, a = 1, a = 1, a = 1, a = 1`

would be a solution with a gap size of 2 (distance of 3).

How do I find all gap sizes that are possible to fill said array with the given constraints?

Imagine a street inbetween two crossroads where a lamppost should be placed on each crossroad and then additional lampposts should be placed equidistant to each other and for some reason only natural number distances are allowed.

(The actual problem I want to solve is where to place Sea Lanterns in my Minecraft Project so do not disregard this problem as an assignment question I want a solution for.) Posted on Categories proxies