Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

single line graph puzzle 1

Status
Not open for further replies.

Olaf Doschke

Programmer
Oct 13, 2004
14,847
DE
How can you connect these nine points with a line drawn in a single stroke with only four segments!

Code:
.       .       .



.       .       .



.       .       .

Here's an exemple on how it does not work, because the left middle point is not on the graph.

Code:
.-------.-------.
 \_             !
   \_           !
     \_         !
.      \.       .
         \_     !
           \_   !
             \_ !
.-------.------\.

Bye, Olaf.
 
6x6 Solution
[tt].! A B C D E F @
.
. G H I J K L
.
. M N O P Q R
.
. S T U V W X
.
. Y Z 1 2 3 4
.
. 5 6 7 8 9 0 #
.
. $[/tt]
About the same as the 5x5, but I'm going to run through it backwards to make it easier to find where # and ! should be.
X to 8 [X,3,8]
8 to # [9,0]
# to ! [4,U] It's probably easiest to figure out where # and ! are if you draw a line through 4 and U.
! to @ [A,B,C,D,E,F]
@ to $ [R,W,2,7]
$ to G [5,Y,S,M,G]
G to L [H,I,J,K,L]
L to 6 [Q,V,1,6]
6 to N [Z,T,N]
N to P [O,P]
It looks like the solution builds off the previous with the last two lines catching a couple of the extra dots. I have a solution that's about the same, but would add two lines to the begining of this solution. It's just figuring out which two dots the long diagonal (# to !) hits. If we make it a battleship grid it'd run through D3 & E6.

If you read the spoiler, I also solved the 7x7 (I'll post the complete solution if someone asks). I would imagine you can keep building up from this solution to work any n x n grid.
 

Skie: Congratulations on finding a fourth way to do the 4x4. I had not seen that particular one before. (This is exactly why I posted the puzzle -- I want to find more solutions.)

However, I don't think your 5x5 is correct. Your line from 1 to 4 which passes thru both T and M also passes thru F which makes a second visit to that point.

The 6x6 is beautiful. Nice job!

By all means, please post the 7x7

 
You're right, my 5x5 would hit "F" twice. It doesn't with my not evenly spaced dots with not-quite straights lines. :D
5x5 Fixed
In order to avoid the hit at "F" twice. Erase the line starting at 1 until it's just over the original starting point. Then move the starting point of L just above it so those 2 lines cross

This should cause it to start at A and end at O

7x7 Solution
[tt]0 1 2 3 4 5 6 7 8
A . . . . . . .
B . . . . . . .
C . . . . . . .
D . . . . . . .
E . . . . . . .
F . . . . . . .
G . . . . . . .
H[/tt]

1: C4 to C2
2: C2 to F2
3: F2 to B6
4: B6 to B1
5: B1 to H1
6: H1 to A8
7: A8 to A0
8: A0 to G8 (Runs through D3 and E6)
9: G8 to G3
10: G3 to D7
11: D7 to F7
12: F7 to F5
 

Excellent! I think your 5x5 is different from either of the two that I found. That makes at least three distinct ways to do a 5x5, and four distinct ways to do a 4x4.

Nice job on the 7x7. One typo: Line 10 s/b C7, not D7.

I still don't see any general solution, since all of the ones found so far visit virtual dots outside of the current grid, preventing a simple turn and go algorithm.

 
I don't know if there's an algorithm, but the solutions have a common pattern. I quickly worked up an two 8x8 solutions, one that's like 7x7 and one that's like 5x5 (fixed) solution. The only hard part is figuring out where the triangle-joining diagonal is and making sure it doesn't double-dot.

What I wonder is given the multiple solutions for larger girds if it's possible to use less lines.
 
I've come up with two more 6x6 solutions. I haven't been able to find a way to get it down to 9 lines though. It seems I always end up with two dots that require a diagonal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top