This is the same question posted by webadventurer with one extra condition (number 5) that disallows the previous solution posted here.

(All credits go to webadventurer, including all images.)


  1. Line must be straight.
  2. Line must be continuous.
  3. Line must not intersect itself.
  4. Line is allowed to take 45 degree turns to itself, for example:

angle rule

5. Line must not leave the square.

The dots:



2 Answers 2


I mean, as long as the number of segments doesn't matter..

enter image description here


This might be the intended answer. Only slightly out of the box.

enter image description here

Then of course, people want to know what is the minmum.

OK, I tried. I managed to go down to ...

21 lines instead of 25.

enter image description here

But somehow the apparent waste at the ends is not very satisfactory.

  • $\begingroup$ Also a good answer! I decided to award Bass the tick as they have posted the answer first, though your answer is quite elegant. $\endgroup$ Commented Sep 1, 2023 at 7:23
  • 1
    $\begingroup$ No problem. Actually his answer inspired mine. $\endgroup$
    – Florian F
    Commented Sep 1, 2023 at 7:36
  • 3
    $\begingroup$ @CatProgrammer: The next question is... what is the minimum number of bends? $\endgroup$
    – user21820
    Commented Sep 1, 2023 at 12:37
  • $\begingroup$ Surely "inside the square" still gives you some margin to go a little bit past the centres of the outer dots? $\endgroup$ Commented Sep 2, 2023 at 13:19
  • $\begingroup$ Maybe, but I am a bit purist. Taking the square of dots as the limit makes more sense. The frame around it is of an unspecified and arbitrary size. $\endgroup$
    – Florian F
    Commented Sep 2, 2023 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.