Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Coding: Pathfinder. Write a text?based program that reads a set of points from a text file and outputs on the screen the path (i.e.

Python Coding:

Pathfinder. Write a text?based program that reads a set of points from a text file and outputs on the screen the path (i.e. sequence of points) that visits all the points starting always from the first point in the file, and at every step moving to the nearest point that has not yet been visited. The maximum number of points in the file is 10. The format of the text file consists of one point per line where the x,y point is described by two integer numbers between 0 and 100 separated by a coma and with no blank spaces in between.

Example: a file with a set of four points would be as follows:

4,2

1,8

7,5

10,3

The path the program needs to find must start from 4,2 because thats the first point in the file. From there, the program must continue to 7,5 because it is the closest point to 4,2. Thus, the next point must be 10,3 because it is the closest point to 7,5. The final point must be 1,8. The screen output should look like this: 4,2 --- 7,5 --- 10,3 --- 1,8.

To run the program the user should type python pathfinder, and then the program should ask the user to enter the name of the file containing the points.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

A tool which edits images, or a person who edits images

Answered: 1 week ago