A weather institute receives a file with daily measurements of the ozone content on a few measurement locations. The ozone content is expressed as a real number and the measurement locations are represented with a string. Your job is to determine in which locations the ozone content is higher than the critical value for more than \(k\) days.

Design and implement an algorithm for this problem.

Assignment

Write a Python function riskAreas(measurements: list, k: int, criticalValue: float ), with a list of measurements, an integer \(k\), and a real number representing the critical value as its arguments. The elements in the list of measurements are of the type tuple(str, float) the string represents the location and the float the measurements. The output of the program is a set containing the locations where the critical value has been exceeded \(k\) number of times.

Examples

>>> riskAreas([("Gent",90.1),("Antwerpen",120.9),("Brussel",181.1),("Brugge",70.7),("Gent",150.50),("Antwerpen",190.3),("Brussel",179.4),("Brugge",120.2),("Gent",190.2),("Antwerpen",185.1),("Brussel",200.1),("Brugge",110.1), ("Gent",160.4),("Antwerpen",162.1),("Brussel",190.9),("Brugge",120.1),("Gent",180.7),("Antwerpen",125.3),("Brussel",190.1),("Brugge",177.5)], 2, 180)
{'Brussel'}
>>> riskAreas([("Gent",90.1),("Antwerpen",120.9),("Brussel",181.1),("Brugge",70.7),("Gent",150.50),("Antwerpen",190.3),("Brussel",179.4),("Brugge",120.2),("Gent",190.2),("Antwerpen",185.1),("Brussel",200.1),("Brugge",110.1),("Gent",160.4),("Antwerpen",182.1),("Brussel",190.9),("Brugge",120.1),("Gent",180.7),("Antwerpen",125.3),("Brussel",190.1),("Brugge",177.5)], 1, 180 )
{'Antwerpen', 'Gent', 'Brussel'}
>>> riskAreas([("Gent",90.1),("Antwerpen",120.9),("Brussel",181.1),("Brugge",70.7),("Gent",150.50),("Antwerpen",190.3),("Brussel",179.4),("Brugge",120.2),("Gent",190.2),("Antwerpen",185.1),("Brussel",200.1),("Brugge",110.1),("Gent",160.4),("Antwerpen",182.1),("Brussel",190.9),("Brugge",120.1),("Gent",180.7),("Antwerpen",125.3),("Brussel",190.1),("Brugge",177.5),("Gent",155.2),("Antwerpen",199.2),("Brussel",200.1),("Brugge",160.1),("Gent",145.2),("Antwerpen",179.2),("Brussel",170.1),("Brugge",150.1),("Gent",185.2),("Antwerpen",190.2),("Brussel",185.3),("Brugge",160.7)], 3, 180)
{'Antwerpen', 'Brussel'}

References