cs102 lab3


http://www.maths.nuigalway.ie/~gettrick/teach/cs102/2024/labs/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 4 or 5 businesses ("for free"), that neighbor one another. The problem is to calculate which 4 or 5 we should take to maximize our yearly profit.
Given these numbers, write a PYTHON program to calculate which 4 or 5 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 last 5 businesses (our overall profit would then be 20).
Run your program on the two lists at https://maths.nuigalway.ie/~gettrick/teach/cs102/2024/labs/shops.txt and submit your answers with your program.

© University of Galway