Input:

The input file is a stream of values read from sensors.

Each row represents a single reading from a specific sensor containing volume and temperature.

The input is a time series of values in columns:

< TimeStamp>,< Sensor>,< Volume>,< Temperature>

Definitions

  • TimeStamp is value indicating the microseconds since midnight.
  • Symbol is the 3 character unique identifier for a sensor
  • Volume is the volume included in this reading
  • Temperature is the average temperature during the period of the reading.

Safe Assumptions:

  • TimeStamp - Always for the same day. Midnight is 0, and no rollover occurs. TimeStamp never decreases.
  • Volume - volume is in liters and integer based, there will be no fractional measurements.
  • Temperature - Temperature is measured in Kelvin, and will never be less than 0.

Even though input file is small, the program must be able to handle a dataset well beyond the space available on the computer.

Example: here is a row for a reading of 10L from sensor aaa at a temperature of 120 degrees K: 1234567,aaa,10,120

Problem:

Find the following on a per sensor basis:

  • Maximum time gap
    (time gap = Amount of time that passes between consecutive readings of a sensor) if only 1 reading is in the file then the gap is 0.
  • Total Volume
    (Sum of the volume for all readings from a sensor).
  • Max Temperature
  • Weighted Average Temperature. Average temperature per liter not per reading.

Report results in integers, no fractional values needed.

Example: the following readings
20L on aaa @ 18 degrees
5L of aaa @ 7 degrees
Weighted Average Temperature = ((20 * 18) + (5 * 7)) / (20 + 5) = 15 degrees

Output:

Your solution should produce a file called 'output.csv'.

file should be a comma separate file with this format:

< sensor>,< MaxTimeGap>,< Volume>,< WeightedAverageTemperature>,< MaxTemperature>

The output should be sorted by sensor ascending ('aaa' should be first).

Sample Input:

52924702,aaa,13,1136
52924702,aac,20,477
52925641,aab,31,907
52927350,aab,29,724
52927783,aac,21,638
52930489,aaa,18,1222
52931654,aaa,9,1077
52933453,aab,9,756

Sample Output:

aaa,5787,40,1161,1222
aab,6103,69,810,907
aac,3081,41,559,638
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.