# Minimize distance between figures while satisfying some constraints

I'd like your help in solving the following problem. I have 2 black figures (left and right). I have to join them as close as possible by moving them only in right or left direction, while satisfying the following constraints:

1. red figures can be unioned with red, blue and green.
2. blue figures can be unioned with blue, red but not green
3. green figures can be unioned only with red
4. black figures can't be unioned

Color figures can't change position relative to the black figure. And each black figure have attached 1 blue, 1 red and 1 green figure.

Figures shape can be anything

How to solve this problem?

• As stated, the question is not very clear: what's the X axis? Can we separate out the blue part from the black? What about the red and green? Commented Nov 1, 2017 at 5:59
• @Raskolnikov, thank you for your note. I tried to make more transparent explanation of axis X:) Red and green can be unioned (see p.1, 3) Commented Nov 1, 2017 at 6:06
• @Raskolnikov I also added explanation about how zones are grouped. I hope it is clear now. Commented Nov 1, 2017 at 6:12
• One more question: in the process of moving the figures, is it allowed that for instance blue and green overlap as long as in the final state they do not? Commented Nov 1, 2017 at 8:48
• @Raskolnikov yes Commented Nov 1, 2017 at 8:49