CT240 lab5
http://geminga.it.nuigalway.ie/~gettrick/courses/CT240/labs/l5.html
-
For this lab you must submit a printout of all source code (python
files), and the result(s) of running the program on (a few)
test cases.
The source code must
be well presented (indenting, spaces, reasonable variable/function names,
etc.) and must include comments (as a rough guideline - aim to have nearly as
many comments as lines of code). Any questions asked should be answered on a plain sheet of paper.
-
The above material should be given to Paul or left in the cardboard box marked CT240 in the mail room (room IT415) on the 4th floor of the IT Building
before
the deadline of 5pm
Monday 20th. October 2008. You will lose 20% for each day
(or part of day) the lab is late. If you have a genuine reason for
submitting a late lab, please contact Paul before the lab
due date/time.
-
Plagiarism (the unattributed copying of work from other sources
(internet, fellow students,....)) will not be tolerated. Please see
http://www.nuigalway.ie/engineering/documents/plagiarism_guide_students
_v4.pdf. You risk getting zero for your lab if it is found to be
plagiarized.
Consider the (20x20) array of numbers here.
Lets say this represents a matrix A of distances (in kilometers) between
cities. Note that A is symmetric A(i,j) = A(j,i) and all its diagonal
elements are zero. Suppose Vladimir from city i and Petra from city j want
to meet up in some third city k (i, j and k are all different).
Conscious about their carbon footprint (!), they want k to be as near as
possible: specifically the sum of the distances both has to travel
should be minimum. Given i and j, write a program in PYTHON that
determines what k should be. (In PYTHON you can store the matrix as
a list of lists). Do not worry in your program about
"reading in" A: Just hard code it in to the code.
You should read in from the user the
two cities (i and j) where Vladimir and Petra live.
From your program, calculate the answer for
-
1. i=3, j=13
-
2. i=18, j=4
©
NUI, Galway