A Computer Science /Math Algorithm Problem?

You’re never actually going to get an algorithm if you add new considerations with every post.

And the analogy to people sitting together at a ballgame doesn’t really work, either, because it’s imprecise. For example, if I were at a ballgame,

AAAAA
AAAAA
AAAAA

is far superior to

AAAAAAA
AAAAAAA
A

Who do you make sit by himself? The weird uncle no one likes?

But you’re saying it’s not. So… you know, specify what you’re actually trying to do. I know this is GQ, but it’s frustrating as hell. “I have a problem that I want an answer to, but I don’t really know what the problem is”. It took this many posts for you to even mention that it wasn’t a strictly row-based problem. Look at all the work that BarryB did that won’t work because you’re not actually stating the problem.

In defense of the OP, I have done the same myself as I work on algorithms - as I peel the onion I realize the subtle complexity that seemed so easy to summarize in my head.

Maybe the algorithm is to run various pairs of solutions through a neural network with the OP’s judgement regarding which is better as the target output, and then new pairs of solutions can at least be compared. Iterate through the combinations and eventually you will have an answer (not optimal).

We decided to use a “good enough” algorithm to solve the problem. Ultimately the user is gonna be able to rearrange chip positions manually so the algorithm doesn’t have to do a perfect job. Our approach:
[ul]
[li]Sort the colors by total number of chips in them.[/li][li]While there are still empty rows left put the next largest(most chips) color into the empty row.[/li][li]Once there are no more empty rows, fill in the left over space with whatever chips are left, if the number of left over spaces ever match the number of chips of a leftover color, put them in before putting in anything else.[/li][/ul]

BarryB thanks for the detailed solution, it went over my head as I haven’t sat in a math or algorithms classroom for much too long, but I appreciate the effort.