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.)
Rules:
- Line must be straight.
- Line must be continuous.
- Line must not intersect itself.
- Line is allowed to take 45 degree turns to itself, for example:
5. Line must not leave the square.
The dots: