cs102 lab2
http://www.maths.nuigalway.ie/~gettrick/teach/cs102/labs/l2.html
-
For this lab you must submit all source code (python
files), and, if applicable, the result(s) of running the program on (a few)
test cases. This should be sent in via BLACKBOARD (not directly by email).
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 by
typing the answers into the relevant box on the BLACKBOARD upload form.
-
This material should be uploaded
before
the deadline of 5pm
Saturday February 4th, 2017. You will lose 20% for each day
(or part of day) the lab is late.
-
Plagiarism (the unattributed copying of work from other sources
(internet, fellow students,....)) will not be tolerated.
You risk getting zero for your lab if it is found to be
plagiarized.
This lab is based on the same idea as lab 1:
We have a list of integers, representing the
yearly profit (in kilo euro) of n businesses (shops) along the
high street in the City centre. This time we are being given 4
(four) businesses ("for free"), that neighbor one another. The
problem is to calculate which 4 we should take to maximize our
yearly profit.
Given these numbers, write a
PYTHON
program to calculate which 4 we should take.
As examples:
-
If the profits were 52, 67, -8, 43, -20
we should take the first 4 businesses.
-
If the profits were -20, 36, -10, -30, 3, 21
we would take no business (this is also allowed).
Run your program on the two lists at
http://www.maths.nuigalway.ie/~gettrick/teach/cs102/labs/shops.txt
and submit your answers with your program
©
NUI, Galway