- Go through each line in the list in order of length
- If both points of the line are not handled twice ( connected on either side ), place it into the path
- Quit when every point (state capital) is hit twice
This gives you all the points, but it does not give you an order.
- pull line out of path
- for each line in the path
- check if one of the points
- if one of the points is the one we want, throw it into the output array
- else put it into the dummy path array
- push line into path
There is a problem, however.
Nothing I have done guarantees that all the states are connected. And in this case, I know that the states are not all connected.
Back to the drawing board.
No comments:
Post a Comment