# Maximum possible coincidences? Python code please

Given $$M = [0,4,8,15]$$ as points on a real line place 2 points $$C_1$$, $$C_2$$ on the line according to the following conditions

Both $$C_1$$ and $$C_2$$ cannot be placed at 0 or 15.

Distance between $$C_1$$ and $$C_2$$ should be $$\leq$$ $$7$$

Distance between first point in M (that is 0) and $$C_1$$ should be $$\leq$$ $$7$$

Distance between last point in M( that is 15) and $$C_2$$ should be $$\leq$$ $$7$$

The objective is to place points $$C_1$$ , $$C_2$$ in such a way that maximum number of points of $$C_1$$ , $$C_2$$ (which is 0 or 1 or 2) coincide with points in $$M$$

Solution : $$C_1$$ can be placed at $$4$$ and $$C_2$$ can be placed at $$8$$ so that maximum number of points i,e.,2 are placed so that they coincide with $$M$$ points and they satisfy all the conditions

• Have a (another) look at the info for tag python. Nov 19 at 8:36
• An an exception, here is some python code that provides the solution print("C1 = 4; C2=8.") Nov 19 at 9:13