Ruler on cube problem

Question

Hints

Answer