I need an algorithm that distributes same items across a list, so maximizing the distance between occurrences.
E.g. I have a list of 15 items:
The algorithm should reorder these in such a way that all the duplicates are spread as uniformly as possible.
The mentioned list should result in something like this:
Preferably I'd like pseudo code, and even better would be TSQL (since that is the platform it needs to run on). It needs to process hundreds of these lists in one go.
I also tested a proposed method called 'Weighted shuffle' but this will still allow two of the same items in the list to appear next to each other even when this is not needed.