Starting from:
$35

$29

Programming Assignment 1 Lists and Files Solution

Description: For this assignment, you will write a short Python program that gathers a data element from each of a number of data les. It will then determine the minimum and mean values for that data element and report them. The data represent runs of a traveling salesman algorithm. The data element we want to evaluate represents the length of the shortest path found during a run of the algorithm. Our goal, is to nd the overall minimum and mean for a large number of runs of the algorithm.

Details: The zipped le you downloaded includes this assignment writeup and a directory called datafiles that includes approximately 100 directories. Each directory has a name of the form run.xxx, where xxx is an integer. You cannot depend on those integers being consecutive. Within each directory, there are several les. The le we are interested in has the name run.xxx.runbest, where xxx is the same integer as in the directory name.


Each runbest le contains a single line. Reading that line gives you a string. From that string, you must access the minumum distance, which is preceded by F. Here is an example line from one of the les:

G 1265 I 5091 L 55 F 79666.000 -1.000 ( 0, 7935) 5 4 18 50 47 15 32 12 11 10363551140414216734983320260282729303817373124 2125394934821365419525323224346454414

In this example line, the value of interest is 79666:0. The rest of the line is not relevant for this assignment.

Your program should produce concise, easy-to-read output that conveys all required information: number of runs represented, minimum value, and mean value.












1
Adhere to common coding conventions and comment your code.. Include a comment at the top that looks like this:

#



    • Programming Assignment 1

    • 
    • This program performs simple analysis of a data element across a

    • large number of data files representing  runs of a traveling salesman

    • algorithm.

#

    • Author: Your name here


    • 



Submission: The name of your program should be analyze.py. Submit your solution as a compressed directory by 11:59 PM on the due date.





































2

More products