cs102 lab3
http://www.maths.nuigalway.ie/~gettrick/teach/cs102/labs/2021labs/l3.html
-
For this lab you must submit all source code
(python .PY
files or jupyter .IPYNB notebooks),
and, if applicable, the result(s) of running the program on (a few)
test cases. This should be uploaded in 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 March 13th, 2021. 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. We are being given either 3 or 4
businesses ("for free"), that neighbor one another. The
problem is to calculate which 3 or 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 (with corresponding overall profit 154).
-
If the profits were -20, 36, -10, -30, 3, 21
we would take the first 3 businesses (our overall profit would then be 6).
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