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?

2 figures to join

  • $\begingroup$ 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? $\endgroup$ Commented Nov 1, 2017 at 5:59
  • $\begingroup$ @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) $\endgroup$ Commented Nov 1, 2017 at 6:06
  • $\begingroup$ @Raskolnikov I also added explanation about how zones are grouped. I hope it is clear now. $\endgroup$ Commented Nov 1, 2017 at 6:12
  • $\begingroup$ 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? $\endgroup$ Commented Nov 1, 2017 at 8:48
  • $\begingroup$ @Raskolnikov yes $\endgroup$ Commented Nov 1, 2017 at 8:49

1 Answer 1


Say we call the left pieces L and the right pieces R. I'd approach it as follows: enumerate all positions where two subpieces of L and R are infinitesimally close to each other. This will be a finite number. For each pair of subpieces you have to check infinitesimally close to the left and infinitesimally close to the right of one piece w.r.t. other. This gives 4*4*2=32 positions.

In each of these cases, perform the check of your 4 conditions. If more than one position satisfy the conditions, you'll have to define what you consider to be closer, maybe the total distance of all subpieces has to be smallest.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .