cs102 lab3


http://www.maths.nuigalway.ie/~gettrick/teach/cs102/labs/2021labs/l3.html




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:

  1. If the profits were 52, 67, -8, 43, -20 we should take the first 4 businesses (with corresponding overall profit 154).
  2. 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